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

Side by Side Diff: pkg/analysis_server/lib/src/services/completion/imported_computer.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library services.completion.computer.dart.toplevel; 5 library services.completion.computer.dart.toplevel;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analysis_server/src/protocol_server.dart' 10 import 'package:analysis_server/src/protocol_server.dart'
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 /** 73 /**
74 * [_ImportedSuggestionBuilder] traverses the imports and builds suggestions 74 * [_ImportedSuggestionBuilder] traverses the imports and builds suggestions
75 * based upon imported elements. 75 * based upon imported elements.
76 */ 76 */
77 class _ImportedSuggestionBuilder extends ElementSuggestionBuilder 77 class _ImportedSuggestionBuilder extends ElementSuggestionBuilder
78 implements SuggestionBuilder { 78 implements SuggestionBuilder {
79 bool shouldWaitForLowPrioritySuggestions; 79 bool shouldWaitForLowPrioritySuggestions;
80 final DartCompletionRequest request; 80 final DartCompletionRequest request;
81 final OpType optype; 81 final OpType optype;
82 DartCompletionCache cache; 82 DartCompletionCache cache;
83 HashSet<String> completions;
84 83
85 _ImportedSuggestionBuilder(this.request, this.optype) { 84 _ImportedSuggestionBuilder(this.request, this.optype) {
86 cache = request.cache; 85 cache = request.cache;
87 completions = new HashSet<String>();
88 for (CompletionSuggestion suggestion in request.suggestions) {
89 completions.add(suggestion.completion);
90 }
91 } 86 }
92 87
93 @override 88 @override
94 CompletionSuggestionKind get kind => CompletionSuggestionKind.INVOCATION; 89 CompletionSuggestionKind get kind => CompletionSuggestionKind.INVOCATION;
95 90
96 /** 91 /**
97 * If the needed information is cached, then add suggestions and return `true` 92 * If the needed information is cached, then add suggestions and return `true`
98 * else return `false` indicating that additional work is necessary. 93 * else return `false` indicating that additional work is necessary.
99 */ 94 */
100 bool computeFast(AstNode node) { 95 bool computeFast(AstNode node) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 163
169 /** 164 /**
170 * Add suggestions which start with the given text. 165 * Add suggestions which start with the given text.
171 */ 166 */
172 _addFilteredSuggestions( 167 _addFilteredSuggestions(
173 String filterText, List<CompletionSuggestion> unfiltered) { 168 String filterText, List<CompletionSuggestion> unfiltered) {
174 //TODO (danrubel) Revisit this filtering once paged API has been added 169 //TODO (danrubel) Revisit this filtering once paged API has been added
175 unfiltered.forEach((CompletionSuggestion suggestion) { 170 unfiltered.forEach((CompletionSuggestion suggestion) {
176 if (filterText.length > 0) { 171 if (filterText.length > 0) {
177 if (suggestion.completion.startsWith(filterText)) { 172 if (suggestion.completion.startsWith(filterText)) {
178 _addSuggestion(suggestion); 173 request.addSuggestion(suggestion);
179 } 174 }
180 } else { 175 } else {
181 if (suggestion.relevance != DART_RELEVANCE_LOW) { 176 if (suggestion.relevance != DART_RELEVANCE_LOW) {
182 _addSuggestion(suggestion); 177 request.addSuggestion(suggestion);
183 } 178 }
184 } 179 }
185 }); 180 });
186 } 181 }
187 182
188 /** 183 /**
189 * Add suggestions for any inherited imported members. 184 * Add suggestions for any inherited imported members.
190 */ 185 */
191 void _addInheritedSuggestions(AstNode node) { 186 void _addInheritedSuggestions(AstNode node) {
192 var classDecl = node.getAncestor((p) => p is ClassDeclaration); 187 var classDecl = node.getAncestor((p) => p is ClassDeclaration);
(...skipping 26 matching lines...) Expand all
219 _addElementSuggestions(type.element.methods, 214 _addElementSuggestions(type.element.methods,
220 relevance: DART_RELEVANCE_INHERITED_METHOD); 215 relevance: DART_RELEVANCE_INHERITED_METHOD);
221 } 216 }
222 }); 217 });
223 } 218 }
224 } 219 }
225 } 220 }
226 } 221 }
227 222
228 /** 223 /**
229 * Add suggestion if an identically named suggestion
230 * has not already been added.
231 */
232 void _addSuggestion(CompletionSuggestion suggestion) {
233 if (completions.add(suggestion.completion)) {
234 request.suggestions.add(suggestion);
235 }
236 }
237
238 /**
239 * Add suggested based upon imported elements. 224 * Add suggested based upon imported elements.
240 */ 225 */
241 void _addSuggestions(AstNode node) { 226 void _addSuggestions(AstNode node) {
242 if (optype.includeConstructorSuggestions) { 227 if (optype.includeConstructorSuggestions) {
243 _addConstructorSuggestions(); 228 _addConstructorSuggestions();
244 } 229 }
245 if (optype.includeReturnValueSuggestions || 230 if (optype.includeReturnValueSuggestions ||
246 optype.includeTypeNameSuggestions || 231 optype.includeTypeNameSuggestions ||
247 optype.includeVoidReturnSuggestions) { 232 optype.includeVoidReturnSuggestions) {
248 _addInheritedSuggestions(node); 233 _addInheritedSuggestions(node);
(...skipping 19 matching lines...) Expand all
268 _addFilteredSuggestions(filterText, cache.libraryPrefixSuggestions); 253 _addFilteredSuggestions(filterText, cache.libraryPrefixSuggestions);
269 } 254 }
270 if (optype.includeReturnValueSuggestions) { 255 if (optype.includeReturnValueSuggestions) {
271 _addFilteredSuggestions(filterText, cache.otherImportedSuggestions); 256 _addFilteredSuggestions(filterText, cache.otherImportedSuggestions);
272 } 257 }
273 if (optype.includeVoidReturnSuggestions) { 258 if (optype.includeVoidReturnSuggestions) {
274 _addFilteredSuggestions(filterText, cache.importedVoidReturnSuggestions); 259 _addFilteredSuggestions(filterText, cache.importedVoidReturnSuggestions);
275 } 260 }
276 } 261 }
277 } 262 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698