void (@NotNull PsiPolyadicExpression expression) { super.visitPolyadicExpression(expression); if (!ExpressionUtils.hasStringType(expression)) { return; } final PsiExpression[] operands = expression.getOperands(); final boolean constant = PsiUtil.isConstantExpression(expression); boolean seenString = false; for (int i = 0; i < operands.length; i++) { PsiExpression operand = operands[i]; operand = PsiUtil.skipParenthesizedExprDown(operand); if (operand == null) { return; } if (i > 0 && !seenString) { PsiExpression previous = operands[i - 1]; if (ExpressionUtils.hasStringType(previous)) { seenString = true; } } if (!ExpressionUtils.isEmptyStringLiteral(operand)) { continue; } if ((skipIfNecessary || constant) && !seenString) { if (i == operands.length - 1) { //example (where x is int): // ... + x + ""; continue; } PsiExpression next = operands[i + 1]; if (!ExpressionUtils.hasStringType(next)) { if (operands.length == 2) { //example (where x is int): // "" + x; continue; } if (i == 0) { PsiExpression nextNext = operands[i + 2]; if (!ExpressionUtils.hasStringType(nextNext) || ExpressionUtils.isEmptyStringLiteral(nextNext)) { //example (where x is int): // "" + x + 1 + ...; continue; } } else { //example (where x is int): // ... + x + "" + x + ...; continue; } } } registerError(operand, operand); } }