private static @NotNull ModCommand selectParameters(@NotNull PsiMethod method,
                                                      @NotNull List<PsiParameter> parameters,
                                                      @NotNull Function<List<PsiParameter>, ModCommand> function) {
    if (parameters.size() < 2) {
      return function.apply(parameters);
    }

    List<@NotNull ParameterClassMember> members = sortByParameterIndex(
      ContainerUtil.map(parameters, ParameterClassMember::new), method);
    List<ParameterClassMember> selection = getInitialSelection(method, members);
    return ModCommand.chooseMultipleMembers(
      JavaBundle.message("dialog.title.choose.0.parameters", method.isConstructor() ? "Constructor" : "Method"),
                               members,
                               selection,
                               function.compose(elements -> ContainerUtil.map(elements, e -> ((ParameterClassMember)e).getParameter())));
  }
private static @NotNull ModCommand selectParameters(@NotNull PsiMethod method,
                                                      @NotNull List<PsiParameter> parameters,
                                                      @NotNull Function<List<PsiParameter>, ModCommand> function)