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

Unified Diff: pkg/analysis_server/lib/src/services/completion/dart/imported_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
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/completion/dart/imported_reference_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/imported_reference_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/imported_reference_contributor.dart
index 6a8c367aa39e07ea48c39108f1eda4908a231305..46514910e3633f3e91134c24bb54d7482e24554b 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/imported_reference_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/imported_reference_contributor.dart
@@ -10,6 +10,7 @@ import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
import 'package:analysis_server/src/services/completion/dart/completion_manager.dart';
import 'package:analysis_server/src/services/completion/dart/local_library_contributor.dart';
import 'package:analysis_server/src/services/completion/dart/optype.dart';
+import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/generated/resolver.dart';
@@ -53,6 +54,20 @@ class ImportedReferenceContributor extends DartCompletionContributor {
return EMPTY_LIST;
}
+ // 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;
+ }
+
this.request = request;
this.optype = (request as DartCompletionRequestImpl).opType;
List<CompletionSuggestion> suggestions = <CompletionSuggestion>[];
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698