void (String newText) { try { getPsiManager().addPsiTreeChangeListener(listener); eventsFired = ""; original = getFile().getText(); Document document = PsiDocumentManager.getInstance(getProject()).getDocument(getFile()); ApplicationManager.getApplication().runWriteAction(() -> document.setText(newText)); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); ApplicationManager.getApplication().runWriteAction(() -> document.setText(original)); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); } finally { getPsiManager().removePsiTreeChangeListener(listener); } }