diff options
author | Christophe Rhodes <xof@google.com> | 2020-11-11 16:51:18 +0000 |
---|---|---|
committer | Christophe Rhodes <xof@google.com> | 2020-11-16 16:25:27 +0000 |
commit | 83837fa47f7d39015f0c3351b9599a63be4cd573 (patch) | |
tree | 8ce4b5d960acae62ea09318ab8b350f9c2d1b24e /lint/src | |
parent | 4bb6241adbdc3de4e267b3be60c65b34c09a0261 (diff) | |
download | idea-83837fa47f7d39015f0c3351b9599a63be4cd573.tar.gz |
[lint] fix nullable args to non-nullable function
The signature of GradleDetector.checkDslPropertyAssignment changed,
and then changed back (see the linked bug); in the rollback, this case
in LintIdeGradleVisitor was missed. Fix the handling of the
qualifierExpression for top-level reference expressions with one
argument, and introduce additional defensiveness for the name
of the potential property (though I have never encountered a case
where that is null, the annotations imply it could be).
Bug: 170026127
Test: added
Change-Id: Ic82cd46e869d7230c67536a2e406535b7eb8f6b7
Diffstat (limited to 'lint/src')
-rw-r--r-- | lint/src/com/android/tools/idea/lint/common/LintIdeGradleVisitor.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lint/src/com/android/tools/idea/lint/common/LintIdeGradleVisitor.java b/lint/src/com/android/tools/idea/lint/common/LintIdeGradleVisitor.java index f317eeecdb4..fe7ab85c6a8 100644 --- a/lint/src/com/android/tools/idea/lint/common/LintIdeGradleVisitor.java +++ b/lint/src/com/android/tools/idea/lint/common/LintIdeGradleVisitor.java @@ -219,15 +219,18 @@ public class LintIdeGradleVisitor extends GradleVisitor { if (invokedExpression instanceof GrReferenceExpression) { GrReferenceExpression referenceExpression = (GrReferenceExpression) invokedExpression; GrExpression qualifierExpression = referenceExpression.getQualifierExpression(); + String qualifierName = ""; if (qualifierExpression != null) { - parentName = qualifierExpression.getText(); + qualifierName = qualifierExpression.getText(); } String name = referenceExpression.getReferenceName(); - String value = unnamedArguments.get(0); - GrCommandArgumentList argumentList = applicationStatement.getArgumentList(); - for (GradleScanner detector : detectors) { - detector.checkDslPropertyAssignment(context, name, value, parentName, null, - invokedExpression, argumentList, applicationStatement); + if (name != null) { + String value = unnamedArguments.get(0); + GrCommandArgumentList argumentList = applicationStatement.getArgumentList(); + for (GradleScanner detector : detectors) { + detector.checkDslPropertyAssignment(context, name, value, qualifierName, null, + invokedExpression, argumentList, applicationStatement); + } } } } |