private <E extends Throwable> E doRunWriteCommandAction(@NotNull ThrowableRunnable<E> action) {
      if (myPsiElements.size() > 0 && !FileModificationService.getInstance().preparePsiElementsForWrite(myPsiElements)) {
        return null;
      }

      AtomicReference<Throwable> thrown = new AtomicReference<>();
      Runnable wrappedRunnable = () -> {
        if (myGlobalUndoAction) {
          CommandProcessor.getInstance().markCurrentCommandAsGlobal(myProject);
        }
        ApplicationManager.getApplication().runWriteAction(() -> {
          try {
            action.run();
          }
          catch (Throwable e) {
            thrown.set(e);
          }
        });
      };
      CommandProcessor.getInstance().executeCommand(myProject, wrappedRunnable, myCommandName, myGroupId,
                                                    ObjectUtils.notNull(myUndoConfirmationPolicy, UndoConfirmationPolicy.DO_NOT_REQUEST_CONFIRMATION),
                                                    myShouldRecordActionForActiveDocument);
      //noinspection unchecked
      return (E)thrown.get();
    }
private <E extends Throwable> E doRunWriteCommandAction(@NotNull ThrowableRunnable<E> action)