@ApiStatus.Internal
  public final synchronized @NotNull ActionInGroup addAction(@NotNull AnAction action,
                                                             @NotNull Constraints constraint,
                                                             @NotNull Function<@NotNull AnAction, @Nullable String> actionToId) {
    if (action == this) {
      throw newThisGroupToItselfAddedException();
    }

    if (!(action instanceof Separator) && containsAction(action)) {
      LOG.error(newDuplicateActionAddedException(action));
      remove(action, actionToId.apply(action));
    }

    constraint = (Constraints)constraint.clone();

    if (constraint.myAnchor == Anchor.FIRST) {
      mySortedChildren.add(0, action);
    }
    else if (constraint.myAnchor == Anchor.LAST) {
      mySortedChildren.add(action);
    }
    else {
      myPendingActions.add(action);
    }
    myConstraints.put(action, constraint);
    addAllToSortedList(actionToId);
    incrementModificationStamp();
    return new ActionInGroup(this, action);
  }
@ApiStatus.Internal
  public final synchronized @NotNull ActionInGroup addAction(@NotNull AnAction action,
                                                             @NotNull Constraints constraint,
                                                             @NotNull Function<@NotNull AnAction, @Nullable String> actionToId)