| OLD | NEW |
| 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' | 10 import 'package:analysis_server/src/protocol_server.dart' |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 _importedCompletions.add(suggestion.completion); | 270 _importedCompletions.add(suggestion.completion); |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 | 273 |
| 274 /** | 274 /** |
| 275 * Add suggestions for all top level elements in the context | 275 * Add suggestions for all top level elements in the context |
| 276 * excluding those elemnents for which suggestions have already been added. | 276 * excluding those elemnents for which suggestions have already been added. |
| 277 */ | 277 */ |
| 278 void _addNonImportedElementSuggestions( | 278 void _addNonImportedElementSuggestions( |
| 279 List<SearchMatch> matches, Set<LibraryElement> excludedLibs) { | 279 List<SearchMatch> matches, Set<LibraryElement> excludedLibs) { |
| 280 AnalysisContext sdkContext = context.sourceFactory.dartSdk.context; |
| 280 matches.forEach((SearchMatch match) { | 281 matches.forEach((SearchMatch match) { |
| 281 if (match.kind == MatchKind.DECLARATION) { | 282 if (match.kind == MatchKind.DECLARATION) { |
| 282 Element element = match.element; | 283 Element element = match.element; |
| 283 if (element.context == context && | 284 if ((element.context == context || element.context == sdkContext) && |
| 284 element.isPublic && | 285 element.isPublic && |
| 285 !excludedLibs.contains(element.library) && | 286 !excludedLibs.contains(element.library) && |
| 286 !_importedCompletions.contains(element.displayName)) { | 287 !_importedCompletions.contains(element.displayName)) { |
| 287 _addSuggestion(element, DART_RELEVANCE_LOW); | 288 _addSuggestion(element, DART_RELEVANCE_LOW); |
| 288 } | 289 } |
| 289 } | 290 } |
| 290 }); | 291 }); |
| 291 } | 292 } |
| 292 | 293 |
| 293 /** | 294 /** |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 @override | 384 @override |
| 384 void visitFunctionTypeAliasElement(FunctionTypeAliasElement element) { | 385 void visitFunctionTypeAliasElement(FunctionTypeAliasElement element) { |
| 385 cache._addSuggestion(element, DART_RELEVANCE_DEFAULT); | 386 cache._addSuggestion(element, DART_RELEVANCE_DEFAULT); |
| 386 } | 387 } |
| 387 | 388 |
| 388 @override | 389 @override |
| 389 void visitTopLevelVariableElement(TopLevelVariableElement element) { | 390 void visitTopLevelVariableElement(TopLevelVariableElement element) { |
| 390 cache._addSuggestion(element, DART_RELEVANCE_DEFAULT); | 391 cache._addSuggestion(element, DART_RELEVANCE_DEFAULT); |
| 391 } | 392 } |
| 392 } | 393 } |
| OLD | NEW |