| 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.index; | 5 library services.index; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| 11 import 'package:analyzer/src/generated/engine.dart'; | 11 import 'package:analyzer/src/generated/engine.dart'; |
| 12 import 'package:analyzer/src/generated/html.dart'; | 12 import 'package:analyzer/src/generated/html.dart'; |
| 13 import 'package:analyzer/src/generated/source.dart'; | 13 import 'package:analyzer/src/generated/source.dart'; |
| 14 | 14 |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * A filter for [Element] names. |
| 18 */ |
| 19 typedef bool ElementNameFilter(String name); |
| 20 |
| 21 |
| 22 /** |
| 17 * The interface [Index] defines the behavior of objects that maintain an index | 23 * The interface [Index] defines the behavior of objects that maintain an index |
| 18 * storing relations between [Element]s. | 24 * storing relations between [Element]s. |
| 19 * | 25 * |
| 20 * Any modification operations are executed before any read operation. | 26 * Any modification operations are executed before any read operation. |
| 21 * There is no guarantee about the order in which the [Future]s for read | 27 * There is no guarantee about the order in which the [Future]s for read |
| 22 * operations will complete. | 28 * operations will complete. |
| 23 */ | 29 */ |
| 24 abstract class Index { | 30 abstract class Index { |
| 25 /** | 31 /** |
| 26 * Answers index statistics. | 32 * Answers index statistics. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 43 * [element] - the element that has the relationship with the locations to be | 49 * [element] - the element that has the relationship with the locations to be |
| 44 * returned. | 50 * returned. |
| 45 * | 51 * |
| 46 * [relationship] - the relationship between the given element and the | 52 * [relationship] - the relationship between the given element and the |
| 47 * locations to be returned. | 53 * locations to be returned. |
| 48 */ | 54 */ |
| 49 Future<List<Location>> getRelationships(Element element, | 55 Future<List<Location>> getRelationships(Element element, |
| 50 Relationship relationship); | 56 Relationship relationship); |
| 51 | 57 |
| 52 /** | 58 /** |
| 59 * Returns top-level [Element]s whose names satisfy to [nameFilter]. |
| 60 */ |
| 61 List<Element> getTopLevelDeclarations(ElementNameFilter nameFilter); |
| 62 |
| 63 /** |
| 53 * Processes the given [HtmlUnit] in order to record the relationships. | 64 * Processes the given [HtmlUnit] in order to record the relationships. |
| 54 * | 65 * |
| 55 * [context] - the [AnalysisContext] in which [HtmlUnit] was resolved. | 66 * [context] - the [AnalysisContext] in which [HtmlUnit] was resolved. |
| 56 * [unit] - the [HtmlUnit] being indexed. | 67 * [unit] - the [HtmlUnit] being indexed. |
| 57 */ | 68 */ |
| 58 void indexHtmlUnit(AnalysisContext context, HtmlUnit unit); | 69 void indexHtmlUnit(AnalysisContext context, HtmlUnit unit); |
| 59 | 70 |
| 60 /** | 71 /** |
| 61 * Processes the given [CompilationUnit] in order to record the relationships. | 72 * Processes the given [CompilationUnit] in order to record the relationships. |
| 62 * | 73 * |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 */ | 361 */ |
| 351 static Relationship getRelationship(String identifier) { | 362 static Relationship getRelationship(String identifier) { |
| 352 Relationship relationship = _RELATIONSHIP_MAP[identifier]; | 363 Relationship relationship = _RELATIONSHIP_MAP[identifier]; |
| 353 if (relationship == null) { | 364 if (relationship == null) { |
| 354 relationship = new Relationship(identifier); | 365 relationship = new Relationship(identifier); |
| 355 _RELATIONSHIP_MAP[identifier] = relationship; | 366 _RELATIONSHIP_MAP[identifier] = relationship; |
| 356 } | 367 } |
| 357 return relationship; | 368 return relationship; |
| 358 } | 369 } |
| 359 } | 370 } |
| 360 | |
| 361 | |
| 362 /** | |
| 363 * An element to use when we want to request "defines" relations without | |
| 364 * specifying an exact library. | |
| 365 */ | |
| 366 class UniverseElement extends ElementImpl { | |
| 367 static final UniverseElement INSTANCE = new UniverseElement._(); | |
| 368 | |
| 369 UniverseElement._() : super("--universe--", -1); | |
| 370 | |
| 371 @override | |
| 372 ElementKind get kind => ElementKind.UNIVERSE; | |
| 373 | |
| 374 @override | |
| 375 accept(ElementVisitor visitor) => null; | |
| 376 } | |
| OLD | NEW |