void (@Nullable String message, @NotNull Editor editor, @NotNull String fileText, boolean ignoreTrailingSpaces, @Nullable String filePath) { ApplicationManager.getApplication().runWriteAction(() -> { Document fakeDocument = EditorFactory.getInstance().createDocument(fileText); if (ignoreTrailingSpaces) { ((DocumentImpl)fakeDocument).stripTrailingSpaces(getProject()); } EditorTestUtil.CaretAndSelectionState carets = EditorTestUtil.extractCaretAndSelectionMarkers(fakeDocument); String newFileText = fakeDocument.getText(); String fileText1 = editor.getDocument().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(editor, carets, message); }); }