void () { final PsiFile psiFile = myFixture.addFileToProject("Foo.java", "class Foo {}"); VirtualFile vFile = psiFile.getVirtualFile(); GlobalSearchScope scope = GlobalSearchScope.allScope(getProject()); WriteCommandAction.runWriteCommandAction(getProject(), (Computable<PsiElement>)() -> psiFile.add(getElementFactory().createEnum("SomeEnum"))); WriteCommandAction.runWriteCommandAction(getProject(), (Computable<PsiElement>)() -> CodeStyleManager.getInstance(getProject()).reformat(psiFile)); PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting(); assert JavaPsiFacade.getInstance(getProject()).findClass("Foo", scope) != null; IdeaTestUtil.setModuleLanguageLevel(myFixture.getModule(), LanguageLevel.JDK_1_3); assert ((PsiJavaFile)getPsiManager().findFile(vFile)).getImportList().getNode() != null; GCUtil.tryGcSoftlyReachableObjects(); assert ((PsiJavaFile)getPsiManager().findFile(vFile)).getImportList().getNode() != null; }