Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(731)

Unified Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 1423993005: Quick Fix for CAN_BE_NULL_AFTER_NULL_AWARE. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 1c2e60b1f1027fee689d0dc3521dc08c2c8bd8f1..54041506ec3e575ba6e33bc89e0e33a6cb74d08c 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -219,7 +219,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
@override
Object visitMethodInvocation(MethodInvocation node) {
- _checkForCanBeNullAfterNullAware(node.realTarget);
+ _checkForCanBeNullAfterNullAware(node.realTarget, node.operator);
return super.visitMethodInvocation(node);
}
@@ -237,7 +237,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
@override
Object visitPropertyAccess(PropertyAccess node) {
- _checkForCanBeNullAfterNullAware(node.realTarget);
+ _checkForCanBeNullAfterNullAware(node.realTarget, node.operator);
return super.visitPropertyAccess(node);
}
@@ -465,20 +465,23 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
}
/**
- * Produce a hint if the given [expression] could have a value of `null`.
+ * Produce a hint if the given [target] could have a value of `null`.
*/
- void _checkForCanBeNullAfterNullAware(Expression expression) {
- if (expression is ParenthesizedExpression) {
- _checkForCanBeNullAfterNullAware(expression.expression);
- } else if (expression is MethodInvocation) {
- if (expression.operator?.type == TokenType.QUESTION_PERIOD) {
+ void _checkForCanBeNullAfterNullAware(Expression target, Token operator) {
+ if (operator?.type == TokenType.QUESTION_PERIOD) {
Brian Wilkerson 2015/10/29 14:02:23 It seems strange to have to repeat this test for a
+ return;
+ }
+ if (target is ParenthesizedExpression) {
+ _checkForCanBeNullAfterNullAware(target.expression, operator);
+ } else if (target is MethodInvocation) {
+ if (target.operator?.type == TokenType.QUESTION_PERIOD) {
_errorReporter.reportErrorForNode(
- HintCode.CAN_BE_NULL_AFTER_NULL_AWARE, expression);
+ HintCode.CAN_BE_NULL_AFTER_NULL_AWARE, target);
}
- } else if (expression is PropertyAccess) {
- if (expression.operator.type == TokenType.QUESTION_PERIOD) {
+ } else if (target is PropertyAccess) {
+ if (target.operator.type == TokenType.QUESTION_PERIOD) {
_errorReporter.reportErrorForNode(
- HintCode.CAN_BE_NULL_AFTER_NULL_AWARE, expression);
+ HintCode.CAN_BE_NULL_AFTER_NULL_AWARE, target);
}
}
}
« no previous file with comments | « pkg/analysis_server/test/services/correction/fix_test.dart ('k') | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698