@@ -0,0 +1,1262 @@
+// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.%0Apackage com.intellij.psi.util;%0A%0Aimport com.intellij.history.core.InMemoryLocalHistoryFacade;%0Aimport com.intellij.lang.injection.InjectedLanguageManager;%0Aimport com.intellij.openapi.fileTypes.PlainTextFileType;%0Aimport com.intellij.psi.PsiElement;%0Aimport com.intellij.psi.PsiFile;%0Aimport com.intellij.psi.PsiFileFactory;%0Aimport com.intellij.testFramework.LightCodeInsightTestCase;%0Aimport org.intellij.lang.annotations.Language;%0A%0Apublic class PsiTreeUtilTest extends LightCodeInsightTestCase %7B%0A  public void testFindCommonParentWhenOneElementIsInjectedMustNotReturnFile() %7B%0A    @Language(%22JAVA%22)%0A    String text = %22class S %7B String s= %5C%22%5C%22.replaceAll(%5C%22%5B%3Ccaret%3E%5D%5C%22, %5C%22%5C%22); %7D%22;%0A    configureFromFileText(%22x.java%22, text);%0A    InjectedLanguageManager ilm = InjectedLanguageManager.getInstance(getProject());%0A    assertTrue(ilm.isInjectedFragment(getFile()));%0A    PsiElement element = getFile().findElementAt(getEditor().getCaretModel().getOffset());%0A    assertNotNull(element);%0A    PsiFile file = ilm.getTopLevelFile(element);%0A    PsiElement parent = PsiTreeUtil.findCommonParent(element, file);%0A    assertNull(parent);%0A  %7D%0A%0A%7D%0A

test for IDEA-CR-37390