void (@NotNull PsiElement element) { PsiPolyadicExpression expression = (PsiPolyadicExpression)element; PsiElement parent = expression.getParent(); while (ExpressionUtils.isStringConcatenation(parent)) { expression = (PsiPolyadicExpression)parent; parent = expression.getParent(); } CommentTracker commentTracker = new CommentTracker(); @NonNls final StringBuilder newExpression = new StringBuilder(); if (isPartOfStringBufferAppend(expression)) { final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)parent.getParent(); assert methodCallExpression != null; final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression(); final PsiExpression qualifierExpression = methodExpression.getQualifierExpression(); if (qualifierExpression != null) { final String qualifierText = commentTracker.text(qualifierExpression); newExpression.append(qualifierText); } turnExpressionIntoChainedAppends(expression, newExpression, commentTracker); PsiReplacementUtil.replaceExpression(methodCallExpression, newExpression.toString(), commentTracker); } else { if (!PsiUtil.isLanguageLevel5OrHigher(expression)) { newExpression.append("new StringBuffer()"); } else { newExpression.append("new StringBuilder()"); } turnExpressionIntoChainedAppends(expression, newExpression, commentTracker); newExpression.append(".toString()"); PsiReplacementUtil.replaceExpression(expression, newExpression.toString(), commentTracker); } }