ProblemHighlightType (@NotNull PsiPolyadicExpression expression) { PsiElement parent = PsiTreeUtil.skipParentsOfType(expression, PsiExpression.class); if (parent instanceof PsiNameValuePair || parent instanceof PsiCaseLabelElementList || parent instanceof PsiAnnotationMethod) { return null; } boolean hasString = false; boolean hasNotLiteralExpression = false; boolean hasLiteralExpression = false; for (PsiExpression operand : expression.getOperands()) { // Support for template concatenation is not yet implemented. if (operand instanceof PsiTemplateExpression) { return null; } if (operand instanceof PsiLiteralExpression && ExpressionUtils.hasStringType(operand)) { hasString = true; } // (1 + 2) * 3 + "str" else if (!isOnlyLiterals(operand)) { hasNotLiteralExpression = true; } else { hasLiteralExpression = true; } } // "str" + str if (hasString && hasNotLiteralExpression) { return ProblemHighlightType.WEAK_WARNING; } // (str + str) || "str" + 1 + 2) if (hasNotLiteralExpression || (hasString && hasLiteralExpression) || PsiUtil.isConstantExpression(expression)) { return ProblemHighlightType.INFORMATION; } else { return null; } }