void () { @Language("JAVA") String text = "class S { String s= \"\".replaceAll(\"[<caret>]\", \"\"); }"; configureFromFileText("x.java", text); InjectedLanguageManager ilm = InjectedLanguageManager.getInstance(getProject()); assertTrue(ilm.isInjectedFragment(getFile())); PsiElement element = getFile().findElementAt(getEditor().getCaretModel().getOffset()); assertNotNull(element); PsiFile file = ilm.getTopLevelFile(element); PsiElement parent = PsiTreeUtil.findCommonParent(element, file); assertNull(parent); }