boolean (@Nullable ULiteralExpression expression) { if (expression == null) return false; if (!UastLiteralUtils.isStringLiteral(expression)) return false; if (isPlacedInNonNlsClass(expression) || isPlacedInNonNlsPackage(expression)) return true; UElement parent = UastUtils.getParentOfType(expression, true, UExpressionList.class, UVariable.class, UReturnExpression.class, UCallExpression.class, UBinaryExpression.class); if (parent instanceof UField || parent instanceof ULocalVariable || parent instanceof UParameter) { return isNonNlsAnnotated(parent); } if (parent instanceof UReturnExpression) { return isReturnExpressionInNonNlsMethod((UReturnExpression)parent); } if (parent instanceof UCallExpression) { return isNonNlsArgument(expression, (UCallExpression)parent) || isCallExpressionWithNonNlsReceiver((UCallExpression)parent); } while (parent instanceof UBinaryExpression) { if (!isAssignmentOrComparisonExpression((UBinaryExpression)parent)) { // go upper to find assignment expression (or field/variable declaration) parent = UastUtils.getParentOfType(parent, true, UBinaryExpression.class, UVariable.class); if (parent instanceof UVariable) { return isNonNlsAnnotated(parent); } continue; } UExpression leftOperand = ((UBinaryExpression)parent).getLeftOperand(); //TODO probably this doesn't cover all cases return leftOperand instanceof USimpleNameReferenceExpression && isReferenceToNonNlsElement((USimpleNameReferenceExpression)leftOperand); } //TODO UExpressionList? return false; }