void () { VirtualFile vfile = createChildData(myRoot, "X.java"); @Language("JAVA") String text = "public class X { public int X; }"; setFileText(vfile, text); PsiClass aClass = myJavaFacade.findClass("X", GlobalSearchScope.allScope(getProject())); assertNotNull(aClass); assertTrue(aClass.isValid()); SmartPsiElementPointer classp = createPointer(aClass); SmartPsiElementPointer filep = createPointer(aClass.getContainingFile()); FileContentUtil.reparseFiles(myProject, Collections.singleton(vfile), true); PsiDocumentManager.getInstance(myProject).commitAllDocuments(); assertFalse(aClass.isValid()); PsiElement element = classp.getElement(); assertNotNull(element); assertTrue(element instanceof PsiClass); assertTrue(element.isValid()); assertEquals(vfile, element.getContainingFile().getVirtualFile()); element = filep.getElement(); assertNotNull(element); assertTrue(element instanceof PsiFile); assertTrue(element.isValid()); assertEquals(vfile, element.getContainingFile().getVirtualFile()); }