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

Side by Side Diff: pkg/analysis_server/lib/src/services/completion/dart_completion_cache.dart

Issue 839713002: exclude suggestions from other contexts (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 11 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
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/imported_computer_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.dart.cache; 5 library services.completion.dart.cache;
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' hide Element, 10 import 'package:analysis_server/src/protocol_server.dart' hide Element,
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 246
247 /** 247 /**
248 * Add suggestions for all top level elements in the context 248 * Add suggestions for all top level elements in the context
249 * excluding those elemnents for which suggestions have already been added. 249 * excluding those elemnents for which suggestions have already been added.
250 */ 250 */
251 void _addNonImportedElementSuggestions(List<SearchMatch> matches, 251 void _addNonImportedElementSuggestions(List<SearchMatch> matches,
252 Set<LibraryElement> excludedLibs) { 252 Set<LibraryElement> excludedLibs) {
253 matches.forEach((SearchMatch match) { 253 matches.forEach((SearchMatch match) {
254 if (match.kind == MatchKind.DECLARATION) { 254 if (match.kind == MatchKind.DECLARATION) {
255 Element element = match.element; 255 Element element = match.element;
256 if (element.isPublic && 256 if (element.context == context &&
257 element.isPublic &&
257 !excludedLibs.contains(element.library) && 258 !excludedLibs.contains(element.library) &&
258 !_importedCompletions.contains(element.displayName)) { 259 !_importedCompletions.contains(element.displayName)) {
259 _addSuggestion(element, CompletionRelevance.LOW); 260 _addSuggestion(element, CompletionRelevance.LOW);
260 } 261 }
261 } 262 }
262 }); 263 });
263 } 264 }
264 265
265 /** 266 /**
266 * Add a suggestion for the given element. 267 * Add a suggestion for the given element.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 @override 354 @override
354 void visitFunctionTypeAliasElement(FunctionTypeAliasElement element) { 355 void visitFunctionTypeAliasElement(FunctionTypeAliasElement element) {
355 cache._addSuggestion(element, CompletionRelevance.DEFAULT); 356 cache._addSuggestion(element, CompletionRelevance.DEFAULT);
356 } 357 }
357 358
358 @override 359 @override
359 void visitTopLevelVariableElement(TopLevelVariableElement element) { 360 void visitTopLevelVariableElement(TopLevelVariableElement element) {
360 cache._addSuggestion(element, CompletionRelevance.DEFAULT); 361 cache._addSuggestion(element, CompletionRelevance.DEFAULT);
361 } 362 }
362 } 363 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/imported_computer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698