void () { WriteCommandAction.runWriteCommandAction(getProject(), () -> { long stamp = FileBasedIndex.getInstance().getIndexModificationStamp(StubUpdatingIndex.INDEX_ID, getProject()); PsiFile file = myFixture.addClass("class Foo {}").getContainingFile(); ((PsiJavaFile)file).getImportList().add(JavaPsiFacade.getElementFactory(getProject()).createImportStatementOnDemand("java.io")); assert findClass("Foo") != null; PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); assertTrue(stamp != FileBasedIndex.getInstance().getIndexModificationStamp(StubUpdatingIndex.INDEX_ID, getProject())); stamp = FileBasedIndex.getInstance().getIndexModificationStamp(StubUpdatingIndex.INDEX_ID, getProject()); assert findClass("Foo") != null; PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); assertEquals(stamp, FileBasedIndex.getInstance().getIndexModificationStamp(StubUpdatingIndex.INDEX_ID, getProject())); stamp = FileBasedIndex.getInstance().getIndexModificationStamp(StubUpdatingIndex.INDEX_ID, getProject()); PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting(); PsiManager.getInstance(getProject()).reloadFromDisk(file); assertTrue(stamp != FileBasedIndex.getInstance().getIndexModificationStamp(StubUpdatingIndex.INDEX_ID, getProject())); assert findClass("Foo") != null; PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); assertTrue(stamp != FileBasedIndex.getInstance().getIndexModificationStamp(StubUpdatingIndex.INDEX_ID, getProject())); stamp = FileBasedIndex.getInstance().getIndexModificationStamp(StubUpdatingIndex.INDEX_ID, getProject()); findClass("Foo").replace(findClass("Foo").copy()); assert findClass("Foo") != null; assertEquals(stamp, FileBasedIndex.getInstance().getIndexModificationStamp(StubUpdatingIndex.INDEX_ID, getProject())); }); }