void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { final PsiElement grandParent = element.getParent().getParent(); if (!(grandParent instanceof PsiMethodCallExpression methodCallExpression)) { return; } final PsiExpressionList argumentList = methodCallExpression.getArgumentList(); final PsiExpression[] arguments = argumentList.getExpressions(); if (arguments.length == 0) { return; } @NonNls final StringBuilder newMethodCall = new StringBuilder(methodCallExpression.getMethodExpression().getText()); newMethodCall.append('('); PsiExpression argument = arguments[0]; int usedArguments; if (!(argument instanceof PsiPolyadicExpression)) { if (!TypeUtils.expressionHasTypeOrSubtype(argument, "org.slf4j.Marker") || arguments.length < 2) { return; } newMethodCall.append(argument.getText()).append(','); argument = arguments[1]; usedArguments = 2; if (!(argument instanceof PsiPolyadicExpression)) { return; } } else { usedArguments = 1; } final PsiPolyadicExpression polyadicExpression = (PsiPolyadicExpression)argument; final PsiMethod method = methodCallExpression.resolveMethod(); if (method == null) { return; } final String methodName = method.getName(); final PsiClass containingClass = method.getContainingClass(); if (containingClass == null) { return; } final PsiMethod[] methods = containingClass.findMethodsByName(methodName, false); boolean varArgs = false; for (PsiMethod otherMethod : methods) { if (otherMethod.isVarArgs()) { varArgs = true; break; } } final List<PsiExpression> newArguments = new ArrayList<>(); final PsiExpression[] operands = polyadicExpression.getOperands(); boolean addPlus = false; boolean inStringLiteral = false; boolean isStringBlock = false; StringBuilder logText = new StringBuilder(); int indent = 0; for (PsiExpression operand : operands) { if (ExpressionUtils.isEvaluatedAtCompileTime(operand)) { final String text = operand.getText(); if (ExpressionUtils.hasStringType(operand) && operand instanceof PsiLiteralExpression literalExpression) { final int count = StringUtil.getOccurrenceCount(text, "{}"); for (int i = 0; i < count && usedArguments + i < arguments.length; i++) { newArguments.add(PsiUtil.skipParenthesizedExprDown((PsiExpression)arguments[i + usedArguments].copy())); } usedArguments += count; if (!inStringLiteral) { if (addPlus) { newMethodCall.append('+'); } inStringLiteral = true; } if (!isStringBlock && literalExpression.isTextBlock()) { indent = PsiLiteralUtil.getTextBlockIndent(literalExpression); } isStringBlock = isStringBlock || literalExpression.isTextBlock(); logText.append(literalExpression.getValue()); } else if (operand instanceof PsiLiteralExpression && PsiTypes.charType().equals(operand.getType()) && inStringLiteral) { final Object value = ((PsiLiteralExpression)operand).getValue(); if (value instanceof Character) { logText.append(value); } } else { if (inStringLiteral) { addLogStrings(newMethodCall, logText, isStringBlock, indent); isStringBlock = false; inStringLiteral = false; } if (addPlus) { newMethodCall.append('+'); } newMethodCall.append(text); } } else { newArguments.add(PsiUtil.skipParenthesizedExprDown((PsiExpression)operand.copy())); if (!inStringLiteral) { if (addPlus) { newMethodCall.append('+'); } inStringLiteral = true; } logText.append("{}"); } addPlus = true; } while (usedArguments < arguments.length) { newArguments.add(arguments[usedArguments++]); } if (inStringLiteral) { addLogStrings(newMethodCall, logText, isStringBlock, indent); } if (!varArgs && newArguments.size() > 2) { newMethodCall.append(", new Object[]{"); boolean comma = false; for (PsiExpression newArgument : newArguments) { if (comma) { newMethodCall.append(','); } else { comma = true; } if (newArgument != null) { newMethodCall.append(newArgument.getText()); } } newMethodCall.append('}'); } else { for (PsiExpression newArgument : newArguments) { newMethodCall.append(','); if (newArgument != null) { newMethodCall.append(newArgument.getText()); } } } newMethodCall.append(')'); PsiReplacementUtil.replaceExpression(methodCallExpression, newMethodCall.toString()); }