void () { LanguageLevel level = LanguageLevel.HIGHEST; IdeaTestUtil.setModuleLanguageLevel(myFixture.getModule(), level); PsiFile psiFile = myFixture.addFileToProject("Foo.java", "class Foo {}"); VirtualFile file = psiFile.getVirtualFile(); GlobalSearchScope scope = GlobalSearchScope.allScope(getProject()); PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting(); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); final FileViewProvider vp1 = PsiManager.getInstance(getProject()).findViewProvider(file); WriteCommandAction.runWriteCommandAction(getProject(), (Computable<PsiElement>)() -> { return CodeStyleManager.getInstance(getProject()).reformat(vp1.getPsi(vp1.getBaseLanguage())); }); PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting(); FileContentUtilCore.reparseFiles(Collections.singletonList(file)); final FileViewProvider vp2 = PsiManager.getInstance(getProject()).findViewProvider(file); ((PsiFileImpl)vp2.getPsi(vp2.getBaseLanguage())).getGreenStubTree(); PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting(); FileContentUtilCore.reparseFiles(Collections.singletonList(file)); PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting(); IdeaTestUtil.setModuleLanguageLevel(myFixture.getModule(), level); assert JavaPsiFacade.getInstance(getProject()).findClass("Foo", scope) != null; }