void () { PsiClass aClass = myJavaFacade.findClass("pack.MyInterface1", GlobalSearchScope.allScope(myProject)); TextRange classRange = aClass.getTextRange(); String text = aClass.getText(); BlockSupport blockSupport = myProject.getService(BlockSupport.class); final PsiFile psiFile = aClass.getContainingFile(); ApplicationManager.getApplication().runWriteAction(() -> blockSupport.reparseRange(psiFile, classRange.getStartOffset(), classRange.getEndOffset(), "")); LOG.assertTrue(!aClass.isValid()); ApplicationManager.getApplication().runWriteAction(() -> blockSupport.reparseRange(psiFile, classRange.getStartOffset(), classRange.getStartOffset(), text)); aClass = myJavaFacade.findClass("pack.MyInterface1", GlobalSearchScope.allScope(myProject)); PsiElement[] children = aClass.getChildren(); for (PsiElement child : children) { if (child instanceof PsiModifierList) { PsiElement parent = child.getParent(); assertEquals(aClass, parent); PsiModifierList modifierList = aClass.getModifierList(); assertEquals(modifierList, child); } } PsiJavaFile file = (PsiJavaFile)aClass.getContainingFile(); PsiImportList importList = file.getImportList(); children = importList.getChildren(); int index = 0; for (PsiElement child : children) { if (child instanceof PsiImportStatement) { PsiElement parent = child.getParent(); assertEquals(importList, parent); PsiImportStatement statement = importList.getImportStatements()[index++]; assertEquals(statement, child); } } }