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

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

Issue 1908703002: Code completion improvement, use type information when suggesting constructors, part 2. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rebase with master, comments from danrubel 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/test/services/completion/dart/local_library_contributor_test.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/local_library_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart
index 68beb6a0a4e51fc26f4b8cee0cd4dcbdc8be9545..9814fd6bd55ec26d85efe52f0b2987dfff3e9a38 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart
@@ -11,6 +11,7 @@ import 'package:analysis_server/src/services/completion/dart/completion_manager.
import 'package:analysis_server/src/services/completion/dart/optype.dart';
import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart'
show createSuggestion, ElementSuggestionBuilder;
+import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/visitor.dart';
@@ -51,7 +52,14 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor
}
}
if (optype.includeConstructorSuggestions) {
- _addConstructorSuggestions(element, DART_RELEVANCE_DEFAULT);
+ int relevance = DART_RELEVANCE_DEFAULT;
+ int filter = optype.constructorSuggestionsFilter(element.type);
+ if (filter == null) {
+ return;
+ } else {
+ relevance += filter;
+ }
+ _addConstructorSuggestions(element, relevance);
}
}
@@ -171,6 +179,16 @@ class LocalLibraryContributor extends DartCompletionContributor {
return EMPTY_LIST;
}
+ AstNode node = request.target.containingNode;
+
+ // If the target is in an expression
+ // then resolve the outermost/entire expression
+ await request.resolveContainingExpression(node);
+
+ // Discard any cached target information
+ // because it may have changed as a result of the resolution
+ node = request.target.containingNode;
+
OpType optype = (request as DartCompletionRequestImpl).opType;
LibraryElementSuggestionBuilder visitor =
new LibraryElementSuggestionBuilder(request, optype);
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698