void (@Nullable String message, @NotNull String expectedFileText, boolean ignoreTrailingSpaces, @Nullable String filePath) { bringRealEditorBack(); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); ApplicationManager.getApplication().runWriteAction(() -> { Document document = EditorFactory.getInstance().createDocument(expectedFileText); if (ignoreTrailingSpaces) { ((DocumentImpl)document).stripTrailingSpaces(getProject()); } EditorTestUtil.CaretAndSelectionState carets = EditorTestUtil.extractCaretAndSelectionMarkers(document); PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting(); String newFileText = document.getText(); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); String fileText1 = myFile.getText(); String failMessage = getMessage("Text mismatch", message); if (filePath != null && !newFileText.equals(fileText1)) { throw new FileComparisonFailure(failMessage, newFileText, fileText1, filePath); } assertEquals(failMessage, newFileText, fileText1); EditorTestUtil.verifyCaretAndSelectionState(getEditor(), carets, message, filePath); }); }