private static int findIndex(@NotNull String actionId,
                               @NotNull List<? extends AnAction> actions,
                               @NotNull Function<@NotNull AnAction, @Nullable String> actionToId) {
    for (int i = 0; i < actions.size(); i++) {
      AnAction action = actions.get(i);
      if (action instanceof ActionStub) {
        if (((ActionStub)action).getId().equals(actionId)) {
          return i;
        }
      }
      else {
        String id = actionToId.apply(action);
        if (id != null && id.equals(actionId)) {
          return i;
        }
      }
    }
    return -1;
  }
private static int findIndex(@NotNull String actionId,
                               @NotNull List<? extends AnAction> actions,
                               @NotNull Function<@NotNull AnAction, @Nullable String> actionToId)