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

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

Issue 1536823002: merge completion suggestions based upon relevance (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 years 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/domain_completion_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/completion_manager.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart b/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
index 2adcf96e5c0950fe626e1dc99f553bd050685ba1..2487f66a7feaa35cdfcd98a7bf39b687b004ac29 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
@@ -47,11 +47,21 @@ class DartCompletionManager implements CompletionContributor {
}
// Request Dart specific completions from each contributor
- List<CompletionSuggestion> suggestions = <CompletionSuggestion>[];
- for (DartCompletionContributor c in dartCompletionPlugin.contributors) {
- suggestions.addAll(await c.computeSuggestions(dartRequest));
+ Map<String, CompletionSuggestion> suggestionMap =
+ <String, CompletionSuggestion>{};
+ for (DartCompletionContributor contributor
+ in dartCompletionPlugin.contributors) {
+ for (CompletionSuggestion newSuggestion
+ in await contributor.computeSuggestions(dartRequest)) {
+ var oldSuggestion = suggestionMap.putIfAbsent(
+ newSuggestion.completion, () => newSuggestion);
+ if (newSuggestion != oldSuggestion &&
+ newSuggestion.relevance > oldSuggestion.relevance) {
+ suggestionMap[newSuggestion.completion] = newSuggestion;
+ }
+ }
}
- return suggestions;
+ return suggestionMap.values.toList();
}
}
« no previous file with comments | « no previous file | pkg/analysis_server/test/domain_completion_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698