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

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

Issue 1004343002: Completion should not show overridden inherited methods (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 9 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_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 705b25b68b65e6da606672a655eb65aa61ab7fc6..0f77b19a96a9890feab9745631c3fd5b8b0fb965 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
@@ -317,7 +317,12 @@ class DartCompletionRequest extends CompletionRequest {
/**
* The list of suggestions to be sent to the client.
*/
- final List<CompletionSuggestion> suggestions = <CompletionSuggestion>[];
+ final List<CompletionSuggestion> _suggestions = <CompletionSuggestion>[];
+
+ /**
+ * The set of completions used to prevent duplicates
+ */
+ final Set<String> _completions = new Set<String>();
DartCompletionRequest(this.context, this.searchEngine, this.source,
int offset, this.cache, CompletionPerformance performance)
@@ -344,17 +349,32 @@ class DartCompletionRequest extends CompletionRequest {
}
/**
+ * The list of suggestions to be sent to the client.
+ */
+ Iterable<CompletionSuggestion> get suggestions => _suggestions;
+
+ /**
+ * Add the given suggestion to the list that is returned to the client as long
+ * as a suggestion with an identical completion has not already been added.
+ */
+ void addSuggestion(CompletionSuggestion suggestion) {
+ if (_completions.add(suggestion.completion)) {
+ _suggestions.add(suggestion);
+ }
+ }
+
+ /**
* Convert all [CompletionSuggestionKind.INVOCATION] suggestions
* to [CompletionSuggestionKind.IDENTIFIER] suggestions.
*/
void convertInvocationsToIdentifiers() {
- for (int index = suggestions.length - 1; index >= 0; --index) {
- CompletionSuggestion suggestion = suggestions[index];
+ for (int index = _suggestions.length - 1; index >= 0; --index) {
+ CompletionSuggestion suggestion = _suggestions[index];
if (suggestion.kind == CompletionSuggestionKind.INVOCATION) {
// Create a copy rather than just modifying the existing suggestion
// because [DartCompletionCache] may be caching that suggestion
// for future completion requests
- suggestions[index] = new CompletionSuggestion(
+ _suggestions[index] = new CompletionSuggestion(
CompletionSuggestionKind.IDENTIFIER, suggestion.relevance,
suggestion.completion, suggestion.selectionOffset,
suggestion.selectionLength, suggestion.isDeprecated,

Powered by Google App Engine
This is Rietveld 408576698