void () { PsiClass aClass = myJavaFacade.findClass("AClass",GlobalSearchScope.allScope(getProject())); assertNotNull(aClass); SmartPsiElementPointer pointer = createPointer(aClass); Document document = PsiDocumentManager.getInstance(myProject).getDocument(aClass.getContainingFile()); int offset = aClass.getTextOffset(); insertString(document, offset, "/******/"); pointer.getElement(); insertString(document, offset, "/**/"); PsiDocumentManager.getInstance(myProject).commitAllDocuments(); PsiElement element = pointer.getElement(); assertNotNull(element); assertTrue(element instanceof PsiClass); assertTrue(element.isValid()); }