Skip to content

Commit c7d9fa9

Browse files
bwilkersoncommit-bot@chromium.org
authored andcommitted
Clean up some unnecessary code in completion manager
Change-Id: Ifdbe46f12b82a521aa079db87fd8c1aba9dd165b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151424 Reviewed-by: Jaime Wren <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]>
1 parent e11eb2c commit c7d9fa9

File tree

1 file changed

+1
-58
lines changed

1 file changed

+1
-58
lines changed

pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)