| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 } | 193 } |
| 194 | 194 |
| 195 /** | 195 /** |
| 196 * Add suggestions for implicitly imported elements in dart:core. | 196 * Add suggestions for implicitly imported elements in dart:core. |
| 197 */ | 197 */ |
| 198 void _addDartCoreSuggestions() { | 198 void _addDartCoreSuggestions() { |
| 199 Source coreUri = context.sourceFactory.forUri('dart:core'); | 199 Source coreUri = context.sourceFactory.forUri('dart:core'); |
| 200 LibraryElement coreLib = context.getLibraryElement(coreUri); | 200 LibraryElement coreLib = context.getLibraryElement(coreUri); |
| 201 if (coreLib == null) { |
| 202 // If the core library has not been analyzed yet, then we cannot add any |
| 203 // suggestions from it. |
| 204 return; |
| 205 } |
| 201 Namespace coreNamespace = | 206 Namespace coreNamespace = |
| 202 new NamespaceBuilder().createPublicNamespaceForLibrary(coreLib); | 207 new NamespaceBuilder().createPublicNamespaceForLibrary(coreLib); |
| 203 coreNamespace.definedNames.forEach((String name, Element elem) { | 208 coreNamespace.definedNames.forEach((String name, Element elem) { |
| 204 if (elem is ClassElement) { | 209 if (elem is ClassElement) { |
| 205 importedClassMap[name] = elem; | 210 importedClassMap[name] = elem; |
| 206 } | 211 } |
| 207 _addSuggestion(elem, DART_RELEVANCE_DEFAULT); | 212 _addSuggestion(elem, DART_RELEVANCE_DEFAULT); |
| 208 }); | 213 }); |
| 209 } | 214 } |
| 210 | 215 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 @override | 383 @override |
| 379 void visitFunctionTypeAliasElement(FunctionTypeAliasElement element) { | 384 void visitFunctionTypeAliasElement(FunctionTypeAliasElement element) { |
| 380 cache._addSuggestion(element, DART_RELEVANCE_DEFAULT); | 385 cache._addSuggestion(element, DART_RELEVANCE_DEFAULT); |
| 381 } | 386 } |
| 382 | 387 |
| 383 @override | 388 @override |
| 384 void visitTopLevelVariableElement(TopLevelVariableElement element) { | 389 void visitTopLevelVariableElement(TopLevelVariableElement element) { |
| 385 cache._addSuggestion(element, DART_RELEVANCE_DEFAULT); | 390 cache._addSuggestion(element, DART_RELEVANCE_DEFAULT); |
| 386 } | 391 } |
| 387 } | 392 } |
| OLD | NEW |