void () { final VirtualFile vFile = myFixture.addFileToProject("Foo.java", "").getVirtualFile(); assertNull(findClass("Foo")); PsiFile psiFile = getPsiManager().findFile(vFile); assertNotNull(psiFile); long count = getPsiManager().getModificationTracker().getModificationCount(); final Document document = FileDocumentManager.getInstance().getDocument(vFile); WriteCommandAction.runWriteCommandAction(getProject(), () -> document.insertString(0, "class Foo {}")); FileDocumentManager.getInstance().saveDocument(document); assertEquals(count, getPsiManager().getModificationTracker().getModificationCount()); assertNull(findClass("Foo")); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); assertNotNull(findClass("Foo")); assertNotNull(findClass("Foo").getText()); // if Foo exists now, mod count should be different assertTrue(count != getPsiManager().getModificationTracker().getModificationCount()); }