void () { final VirtualFile vFile = myFixture.addClass("class Foo {}").getContainingFile().getVirtualFile(); assertNotNull(findClass("Foo")); PsiFile psiFile = getPsiManager().findFile(vFile); assertNotNull(psiFile); final Document document = FileDocumentManager.getInstance().getDocument(vFile); WriteCommandAction.runWriteCommandAction(getProject(), () -> document.deleteString(0, document.getTextLength())); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); WriteCommandAction.runWriteCommandAction(getProject(), () -> document.insertString(0, " ")); PsiClass foo = findClass("Foo"); assertNull(foo); }