void (@NotNull PsiElement element) { PsiPolyadicExpression expression = (PsiPolyadicExpression)element; PsiElement parent = expression.getParent(); while (ExpressionUtils.isStringConcatenation(parent)) { expression = (PsiPolyadicExpression)parent; parent = expression.getParent(); } final List<PsiExpression> formatParameters = new ArrayList<>(); final String formatString = StringUtil.escapeStringCharacters(PsiConcatenationUtil.buildUnescapedFormatString(expression, true, formatParameters)); if (replaceWithPrintfExpression(expression, formatString, formatParameters)) { return; } CommentTracker commentTracker = new CommentTracker(); final StringBuilder newExpression = new StringBuilder(); if (HighlightingFeature.TEXT_BLOCKS.isAvailable(element)) { appendFormatString(expression, formatString, false, newExpression); newExpression.append(".formatted("); } else { newExpression.append("java.lang.String.format("); appendFormatString(expression, formatString, false, newExpression); if (!formatParameters.isEmpty()) { newExpression.append(", "); } } newExpression.append(StreamEx.of(formatParameters).map(commentTracker::text).joining(", ")); newExpression.append(')'); PsiReplacementUtil.replaceExpression(expression, newExpression.toString(), commentTracker); }