private static void processParameter(@NotNull Project project,
                                       @NotNull PsiParameter parameter,
                                       @NotNull Set<String> usedNames) {
    PsiType type = FieldFromParameterUtils.getSubstitutedType(parameter);
    JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(project);
    String parameterName = parameter.getName();
    String propertyName = styleManager.variableNameToPropertyName(parameterName, VariableKind.PARAMETER);

    PsiClass targetClass = PsiTreeUtil.getParentOfType(parameter, PsiClass.class);
    if (targetClass == null) return;

    if (!(parameter.getDeclarationScope() instanceof PsiMethod method)) return;

    boolean isMethodStatic = method.hasModifierProperty(PsiModifier.STATIC);

    VariableKind kind = isMethodStatic ? VariableKind.STATIC_FIELD : VariableKind.FIELD;
    SuggestedNameInfo suggestedNameInfo = styleManager.suggestVariableName(kind, propertyName, null, type);
    String[] names = suggestedNameInfo.names;

    boolean isFinal = !isMethodStatic && method.isConstructor();
    String name = names[0];
    for (String curName : names) {
      if (!usedNames.contains(curName)) {
        PsiField fieldByName = targetClass.findFieldByName(curName, false);
        if (fieldByName != null &&
            (!method.isConstructor() || !isFieldAssigned(fieldByName, method)) &&
            fieldByName.getType().isAssignableFrom(parameter.getType())) {
          name = curName;
          break;
        }
      }
    }

    if (usedNames.contains(name)) {
      for (String curName : names) {
        if (!usedNames.contains(curName)) {
          name = curName;
          break;
        }
      }
    }
    
    String fieldName = usedNames.add(name) ? name : JavaCodeStyleManager.getInstance(project).suggestUniqueVariableName(name, parameter, true);

    FieldFromParameterUtils.createFieldAndAddAssignment(project, targetClass, method, parameter, type, fieldName, isMethodStatic, isFinal);
  }
private static void processParameter(@NotNull Project project,
                                       @NotNull PsiParameter parameter,
                                       @NotNull Set<String> usedNames)