@@ -125,8 +125,6 @@ class DartCompletionManager implements CompletionContributor {
125125 ..replacementLength = range.length;
126126
127127 // Request Dart specific completions from each contributor
128- var suggestionMap = < String , CompletionSuggestion > {};
129- var constructorMap = < String , List <String >> {};
130128 var builder = SuggestionBuilder (dartRequest, listener: listener);
131129 var contributors = < DartCompletionContributor > [
132130 ArgListContributor (),
@@ -154,31 +152,6 @@ class DartCompletionManager implements CompletionContributor {
154152 contributors.add (ImportedReferenceContributor ());
155153 }
156154
157- void addSuggestionToMap (CompletionSuggestion newSuggestion) {
158- // TODO(brianwilkerson) After all contributors are using SuggestionBuilder
159- // move this logic into SuggestionBuilder.
160- var key = newSuggestion.completion;
161-
162- // Append parenthesis for constructors to disambiguate from classes.
163- if (_isConstructor (newSuggestion)) {
164- key += '()' ;
165- var className = _getConstructorClassName (newSuggestion);
166- _ensureList (constructorMap, className).add (key);
167- }
168-
169- // Local declarations hide both the class and its constructors.
170- if (! _isClass (newSuggestion)) {
171- var constructorKeys = constructorMap[key];
172- constructorKeys? .forEach (suggestionMap.remove);
173- }
174-
175- var oldSuggestion = suggestionMap[key];
176- if (oldSuggestion == null ||
177- oldSuggestion.relevance < newSuggestion.relevance) {
178- suggestionMap[key] = newSuggestion;
179- }
180- }
181-
182155 try {
183156 for (var contributor in contributors) {
184157 var contributorTag =
@@ -188,17 +161,14 @@ class DartCompletionManager implements CompletionContributor {
188161 performance.logElapseTime (contributorTag);
189162 request.checkAborted ();
190163 }
191- for (var newSuggestion in builder.suggestions) {
192- addSuggestionToMap (newSuggestion);
193- }
194164 } on InconsistentAnalysisException {
195165 // The state of the code being analyzed has changed, so results are likely
196166 // to be inconsistent. Just abort the operation.
197167 throw AbortCompletion ();
198168 }
199169
200170 // Adjust suggestion relevance before returning
201- var suggestions = suggestionMap.values .toList ();
171+ var suggestions = builder.suggestions .toList ();
202172 const SORT_TAG = 'DartCompletionManager - sort' ;
203173 performance.logStartTime (SORT_TAG );
204174 if (ranking != null ) {
@@ -336,33 +306,6 @@ class DartCompletionManager implements CompletionContributor {
336306 }
337307 }
338308 }
339-
340- static List <String > _ensureList (Map <String , List <String >> map, String key) {
341- var list = map[key];
342- if (list == null ) {
343- list = < String > [];
344- map[key] = list;
345- }
346- return list;
347- }
348-
349- static String _getConstructorClassName (CompletionSuggestion suggestion) {
350- var completion = suggestion.completion;
351- var dotIndex = completion.indexOf ('.' );
352- if (dotIndex != - 1 ) {
353- return completion.substring (0 , dotIndex);
354- } else {
355- return completion;
356- }
357- }
358-
359- static bool _isClass (CompletionSuggestion suggestion) {
360- return suggestion.element? .kind == protocol.ElementKind .CLASS ;
361- }
362-
363- static bool _isConstructor (CompletionSuggestion suggestion) {
364- return suggestion.element? .kind == protocol.ElementKind .CONSTRUCTOR ;
365- }
366309}
367310
368311/// The information about a requested list of completions within a Dart file.
0 commit comments