private static void invoke(@NotNull Project project, @NotNull PsiElement element, 
                             @NotNull ModPsiUpdater updater, @NotNull PsiParameter @NotNull [] parameters) {
    final PsiMethod method = PsiTreeUtil.getNonStrictParentOfType(element, PsiMethod.class);
    assert method != null;
    PsiParameterList parameterList = method.getParameterList();
    if (parameters.length == 0) return;
    final PsiMethod methodPrototype = generateMethodPrototype(method, parameters);
    final PsiClass containingClass = method.getContainingClass();
    if (containingClass == null) return;
    final PsiMethod existingMethod = containingClass.findMethodBySignature(methodPrototype, false);
    if (existingMethod != null) {
      updater.moveCaretTo(existingMethod.getTextOffset());
      updater.message(JavaBundle.message("default.param.value.warning",
                                         existingMethod.isConstructor() ? 0 : 1));
      return;
    }

    final PsiMethod prototype = (PsiMethod)containingClass.addBefore(methodPrototype, method);
    CommonJavaRefactoringUtil.fixJavadocsForParams(prototype, Set.of(prototype.getParameterList().getParameters()));

    PsiCodeBlock body = prototype.getBody();
    final String callArgs =
      "(" + StringUtil.join(parameterList.getParameters(), psiParameter -> {
        if (ArrayUtil.find(parameters, psiParameter) > -1) {
          PsiType type = GenericsUtil.getVariableTypeByExpressionType(psiParameter.getType());
          String defaultValue = TypeUtils.getDefaultValue(type);
          return defaultValue.equals(PsiKeyword.NULL) ? "(" + type.getCanonicalText() + ")null" : defaultValue;
        }
        return psiParameter.getName();
      }, ",") + ");";
    final String methodCall;
    if (method.getReturnType() == null) {
      methodCall = "this";
    }
    else if (!PsiTypes.voidType().equals(method.getReturnType())) {
      methodCall = "return " + method.getName();
    }
    else {
      methodCall = method.getName();
    }
    LOG.assertTrue(body != null);
    body.add(JavaPsiFacade.getElementFactory(project).createStatementFromText(methodCall + callArgs, method));
    body = (PsiCodeBlock)CodeStyleManager.getInstance(project).reformat(body);
    final PsiStatement stmt = body.getStatements()[0];
    final PsiExpression expr;
    if (stmt instanceof PsiReturnStatement returnStatement) {
      expr = returnStatement.getReturnValue();
    }
    else if (stmt instanceof PsiExpressionStatement exprStatement) {
      expr = exprStatement.getExpression();
    }
    else {
      expr = null;
    }
    if (expr instanceof PsiMethodCallExpression call) {
      PsiExpression[] args = call.getArgumentList().getExpressions();
      PsiExpression[] toDefaults =
        ContainerUtil.map2Array(parameters, PsiExpression.class, (parameter -> args[parameterList.getParameterIndex(parameter)]));
      ModTemplateBuilder builder = updater.templateBuilder();
      for (PsiExpression exprToBeDefault : toDefaults) {
        if (exprToBeDefault instanceof PsiTypeCastExpression cast && RedundantCastUtil.isCastRedundant(cast)) {
          exprToBeDefault = RemoveRedundantCastUtil.removeCast(cast);
        }
        builder.field(exprToBeDefault, new TextExpression(exprToBeDefault.getText()));
      }
    }
  }
private static void invoke(@NotNull Project project, @NotNull PsiElement element, 
                             @NotNull ModPsiUpdater updater, @NotNull PsiParameter @NotNull [] parameters)