private static void addParameterToConstructor(@NotNull ActionContext context, @NotNull PsiMethod constructor,
                                                @NotNull ModPsiUpdater updater, @Nullable ChainedConstructorData chainedConstructorData, 
                                                @NotNull List<PsiVariable> params) {
    final PsiParameterList parameterList = constructor.getParameterList();

    final Map<PsiField, String> usedFields = new LinkedHashMap<>();
    final MultiMap<PsiType, PsiVariable> types = new MultiMap<>();
    for (PsiVariable param : params) {
      types.putValue(param.getType(), param);
    }

    Project project = context.project();
    PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
    CodeStyleSettings allSettings = CodeStyleSettingsManager.getInstance(project).cloneSettings(CodeStyle.getSettings(context.file()));
    JavaCodeStyleSettings settings = allSettings.getCustomSettings(JavaCodeStyleSettings.class);
    boolean preferLongerNames = settings.PREFER_LONGER_NAMES;
    Ref<PsiElement> prev = Ref.create();
    for (PsiVariable param : params) {
      final PsiType paramType = param.getType();
      if (param instanceof PsiField field) {
        settings.PREFER_LONGER_NAMES = preferLongerNames || types.get(paramType).size() > 1;
        CodeStyle.runWithLocalSettings(project, allSettings, () -> {
          final String uniqueParameterName = getUniqueParameterName(parameterList.getParameters(), param, usedFields);
          usedFields.put(field, uniqueParameterName);
          PsiType type = AnnotationTargetUtil.keepStrictlyTypeUseAnnotations(param.getModifierList(), paramType);
          PsiParameter parameter = factory.createParameter(uniqueParameterName, type, parameterList);
          if (settings.GENERATE_FINAL_PARAMETERS) {
            PsiModifierList modifierList = parameter.getModifierList();
            assert modifierList != null;
            modifierList.setModifierProperty(PsiModifier.FINAL, true);
          }
          if (prev.isNull()) {
            prev.set(parameterList.isEmpty() ? parameterList.add(parameter) :
                     parameterList.addBefore(parameter, parameterList.getParameter(0)));
          }
          else {
            prev.set(parameterList.addAfter(parameter, prev.get()));
          }
        });
      } else {
        prev.set(param);
      }
    }
    if (chainedConstructorData != null) {
      chainedConstructorData.updateChainedCall(constructor, usedFields);
    } else {
      PsiParameter[] newParameters = constructor.getParameterList().getParameters();
      // do not introduce assignment in chained constructor
      for (Map.Entry<PsiField, String> entry : usedFields.entrySet()) {
        PsiField field = entry.getKey();
        final String parameterName = entry.getValue();
        PsiParameter parameter = findParamByName(parameterName, newParameters);
        if (parameter == null) continue;
        NullableNotNullManager.getInstance(field.getProject()).copyNullableOrNotNullAnnotation(field, parameter);
        PsiStatement assignment = AssignFieldFromParameterAction.addFieldAssignmentStatement(project, field, parameter, updater);
        if (assignment != null) {
          CodeStyleManager.getInstance(project).reformat(assignment);
        }
      }
    }
  }
private static void addParameterToConstructor(@NotNull ActionContext context, @NotNull PsiMethod constructor,
                                                @NotNull ModPsiUpdater updater, @Nullable ChainedConstructorData chainedConstructorData, 
                                                @NotNull List<PsiVariable> params)