void () { PsiJavaFile file = (PsiJavaFile)myFixture.addFileToProject("a.java", "class A{public static void foo() { }}"); PsiClass aClass = file.getClasses()[0]; GCWatcher.tracking(aClass.getNode()).ensureCollected(); PsiKeyword kw = assertInstanceOf(aClass.getMethods()[0].getModifierList().getFirstChild(), PsiKeyword.class); kw.delete(); Document document = PsiDocumentManager.getInstance(getProject()).getDocument(file); assertNotNull(document); assertTrue(document.getModificationStamp() != file.getVirtualFile().getModificationStamp()); assertEquals(document.getModificationStamp(), file.getViewProvider().getModificationStamp()); FileDocumentManager.getInstance().saveDocument(document); assertEquals(file.getText(), LoadTextUtil.loadText(file.getVirtualFile()).toString()); }