private void addActionToSharedStack(@NotNull UndoableAction action) {
    if (action instanceof AdjustableUndoableAction adjustable) {
      DocumentReference[] affected = action.getAffectedDocuments();
      if (affected == null) {
        return;
      }

      SharedAdjustableUndoableActionsHolder actionsHolder = myManager.getAdjustableUndoableActionHolder();
      actionsHolder.addAction(adjustable);

      for (DocumentReference reference : affected) {
        for (MutableActionChangeRange changeRange : adjustable.getChangeRanges(reference)) {
          myManager.getSharedUndoStacksHolder().addToStack(reference, changeRange.toImmutable(false));
          myManager.getSharedRedoStacksHolder().addToStack(reference, changeRange.toImmutable(true));
        }
      }
    }
  }
private void addActionToSharedStack(@NotNull UndoableAction action)