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

Unified Diff: pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart

Issue 1876603002: use type information to filter RHS of "is" expression for imported types (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
index cf1977e37706b46d044bbf0c5f4932ef1bb7eabe..8d613cee379354e07aca7c56770a872d7e40a0e2 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
@@ -157,16 +157,22 @@ class LocalReferenceContributor extends DartCompletionContributor {
if (optype.includeReturnValueSuggestions ||
optype.includeTypeNameSuggestions ||
optype.includeVoidReturnSuggestions) {
- _LocalVisitor visitor =
- new _LocalVisitor(request, request.offset, optype);
+ // If the target is in an expression
+ // then resolve the outermost/entire expression
AstNode node = request.target.containingNode;
+ if (node is Expression) {
+ while (node.parent is Expression) {
+ node = node.parent;
+ }
+ await request.resolveExpression(node);
+
+ // Discard any cached target information
+ // because it may have changed as a result of the resolution
+ node = request.target.containingNode;
+ }
// Do not suggest local vars within the current expression
while (node is Expression) {
- // If node is an Expression, ensure that it is resolved. Resolution is
- // used in cases such as the use of optype.typeNameSuggestionsFilter
- // below.
- await request.resolveExpression(node);
node = node.parent;
}
@@ -176,6 +182,8 @@ class LocalReferenceContributor extends DartCompletionContributor {
node = node.parent;
}
+ _LocalVisitor visitor =
+ new _LocalVisitor(request, request.offset, optype);
visitor.visit(node);
return visitor.suggestions;
}

Powered by Google App Engine
This is Rietveld 408576698