void (final Document document1, final String text, UndoConfirmationPolicy policy, String groupId) { CommandProcessor.getInstance().executeCommand(myProject, () -> ApplicationManager.getApplication() .runWriteAction(() -> document1.replaceString(0, document1.getTextLength(), text)), "test_command", groupId, policy); }