@RequiresEdt
  public static boolean executeWriteCommand(@Nullable Project project,
                                            @NotNull Document document,
                                            @Nullable @NlsContexts.Command String commandName,
                                            @Nullable String commandGroupId,
                                            @NotNull UndoConfirmationPolicy confirmationPolicy,
                                            boolean underBulkUpdate,
                                            boolean shouldRecordCommandForActiveDocument,
                                            @NotNull Runnable task) {
    if (!makeWritable(project, document)) {
      VirtualFile file = FileDocumentManager.getInstance().getFile(document);
      String warning = "Document is read-only";
      if (file != null) {
        warning += ": " + file.getPresentableName();
        if (!file.isValid()) warning += " (invalid)";
      }
      LOG.warn(warning);
      return false;
    }

    ApplicationManager.getApplication().runWriteAction(() -> CommandProcessor.getInstance().executeCommand(project, () -> {
      if (underBulkUpdate) {
        DocumentUtil.executeInBulk(document, task);
      }
      else {
        task.run();
      }
    }, commandName, commandGroupId, confirmationPolicy, shouldRecordCommandForActiveDocument, document));
    return true;
  }
@RequiresEdt
  public static boolean executeWriteCommand(@Nullable Project project,
                                            @NotNull Document document,
                                            @Nullable @NlsContexts.Command String commandName,
                                            @Nullable String commandGroupId,
                                            @NotNull UndoConfirmationPolicy confirmationPolicy,
                                            boolean underBulkUpdate,
                                            boolean shouldRecordCommandForActiveDocument,
                                            @NotNull Runnable task)