void (PsiExpression expression, StringBuilder formatString, List<? super PsiExpression> formatParameters, boolean printfFormat, boolean escape) { if (expression instanceof PsiLiteralExpression) { final PsiLiteralExpression literalExpression = (PsiLiteralExpression) expression; final String value = String.valueOf(literalExpression.getValue()); final String text = escape ? StringUtil.escapeStringCharacters(value) : value; String formatText = formatString(text, printfFormat); formatString.append(formatText); } else if (expression instanceof PsiPolyadicExpression) { final PsiType type = expression.getType(); if (type != null && type.equalsToText(JAVA_LANG_STRING)) { final PsiPolyadicExpression binaryExpression = (PsiPolyadicExpression) expression; PsiExpression[] operands = binaryExpression.getOperands(); PsiType first = operands[0].getType(); PsiType second = operands[1].getType(); boolean stringStarted = first != null && first.equalsToText(JAVA_LANG_STRING) || second != null && second.equalsToText(JAVA_LANG_STRING); if (stringStarted) { buildFormatString(operands[0], formatString, formatParameters, printfFormat, escape); } for (int i = 1; i < operands.length; i++) { PsiExpression op = operands[i]; PsiType optype = op.getType(); PsiType r = TypeConversionUtil.calcTypeForBinaryExpression(first, optype, binaryExpression.getOperationTokenType(), true); if (r != null && r.equalsToText(JAVA_LANG_STRING) && !stringStarted) { stringStarted = true; PsiElement element = binaryExpression.getTokenBeforeOperand(op); assert element != null; if (element.getPrevSibling() instanceof PsiWhiteSpace) element = element.getPrevSibling(); String text = binaryExpression.getText().substring(0, element.getStartOffsetInParent()); PsiExpression subExpression = JavaPsiFacade.getElementFactory(binaryExpression.getProject()) .createExpressionFromText(text, binaryExpression); addFormatParameter(subExpression, formatString, formatParameters, printfFormat); } if (stringStarted) { if (optype != null && (optype.equalsToText(JAVA_LANG_STRING) || PsiTypes.charType().equals(optype))) { buildFormatString(op, formatString, formatParameters, printfFormat, escape); } else { addFormatParameter(op, formatString, formatParameters, printfFormat); } } first = r; } } else { addFormatParameter(expression, formatString, formatParameters, printfFormat); } } else { addFormatParameter(expression, formatString, formatParameters, printfFormat); } }