void () { PsiClass aClass = myJavaFacade.findClass("AClass",GlobalSearchScope.allScope(getProject())); final PsiTypeElement typeElement = myJavaFacade.findClass("Test",GlobalSearchScope.allScope(getProject())).getFields()[0].getTypeElement(); SmartPsiElementPointer typePointer = createPointer(typeElement); SmartPsiElementPointer classPointer = createPointer(aClass); Document aClassDocument = PsiDocumentManager.getInstance(myProject).getDocument(aClass.getContainingFile()); Document testDocument = PsiDocumentManager.getInstance(myProject).getDocument(typeElement.getContainingFile()); assertNotSame(aClassDocument, testDocument); insertString(aClassDocument, aClass.getTextOffset(), "/**/"); insertString(testDocument, typeElement.getTextOffset(), "/**/"); PsiDocumentManager.getInstance(myProject).commitAllDocuments(); PsiElement element = typePointer.getElement(); assertNotNull(element); assertTrue(element instanceof PsiTypeElement); assertTrue(element.isValid()); assertEquals(classPointer.getElement(), PsiUtil.resolveClassInType(((PsiTypeElement)element).getType())); }