boolean (@Nullable final PsiExpression expr) { if (expr == null) { return false; } final PsiExpression expression = PsiUtil.skipParenthesizedExprDown(expr); if (expression instanceof PsiLiteralExpression literalExpression) { final String expressionText = literalExpression.getText(); return expressionText.contains("%n"); } if (expression instanceof PsiCallExpression callExpression) { final PsiMethod method = callExpression.resolveMethod(); if (method != null) { final PsiClass aClass = method.getContainingClass(); if (aClass != null && CommonClassNames.JAVA_LANG_STRING.equals(aClass.getQualifiedName())) { final PsiExpressionList argumentList = callExpression.getArgumentList(); if (argumentList != null) { final PsiExpression[] arguments = argumentList.getExpressions(); for (PsiExpression argument : arguments) { if (containsNewlineToken(argument)) { return true; } } return false; } } } } if (expression instanceof PsiPolyadicExpression polyadicExpression) { final IElementType tokenType = polyadicExpression.getOperationTokenType(); if (!tokenType.equals(JavaTokenType.PLUS)) { return false; } final PsiExpression[] operands = polyadicExpression.getOperands(); for (PsiExpression operand : operands) { if (containsNewlineToken(operand)) { return true; } } return false; } // could not be evaluated at compile tie, so possibly contains %n return true; }