| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library services.index_store; | |
| 6 | |
| 7 import 'dart:async'; | |
| 8 | |
| 9 import 'package:analysis_services/index/index.dart'; | |
| 10 import 'package:analyzer/src/generated/element.dart'; | |
| 11 import 'package:analyzer/src/generated/engine.dart'; | |
| 12 import 'package:analyzer/src/generated/source.dart'; | |
| 13 | |
| 14 | |
| 15 /** | |
| 16 * A container with information computed by an index - relations between | |
| 17 * elements. | |
| 18 */ | |
| 19 abstract class IndexStore { | |
| 20 /** | |
| 21 * Answers index statistics. | |
| 22 */ | |
| 23 String get statistics; | |
| 24 | |
| 25 /** | |
| 26 * Notifies the index store that we are going to index an unit with the given | |
| 27 * [unitElement]. | |
| 28 * | |
| 29 * If the unit is a part of a library, then all its locations are removed. | |
| 30 * | |
| 31 * If it is a defining compilation unit of a library, then index store also | |
| 32 * checks if some previously indexed parts of the library are not parts of the | |
| 33 * library anymore, and clears their information. | |
| 34 * | |
| 35 * [context] - the [AnalysisContext] in which unit being indexed. | |
| 36 * [unitElement] - the element of the unit being indexed. | |
| 37 * | |
| 38 * Returns `true` if the given [unitElement] may be indexed, or `false` if | |
| 39 * belongs to a disposed [AnalysisContext], is not resolved completely, etc. | |
| 40 */ | |
| 41 bool aboutToIndexDart(AnalysisContext context, | |
| 42 CompilationUnitElement unitElement); | |
| 43 | |
| 44 /** | |
| 45 * Notifies the index store that we are going to index an unit with the given | |
| 46 * [htmlElement]. | |
| 47 * | |
| 48 * [context] - the [AnalysisContext] in which unit being indexed. | |
| 49 * [htmlElement] - the [HtmlElement] being indexed. | |
| 50 * | |
| 51 * Returns `true` if the given [htmlElement] may be indexed, or `false` if | |
| 52 * belongs to a disposed [AnalysisContext], is not resolved completely, etc. | |
| 53 */ | |
| 54 bool aboutToIndexHtml(AnalysisContext context, HtmlElement htmlElement); | |
| 55 | |
| 56 /** | |
| 57 * Removes all of the information. | |
| 58 */ | |
| 59 void clear(); | |
| 60 | |
| 61 /** | |
| 62 * Notifies that index store that the current Dart or HTML unit indexing is | |
| 63 * done. | |
| 64 * | |
| 65 * If this method is not invoked after corresponding "aboutToIndex*" | |
| 66 * invocation, all recorded information may be lost. | |
| 67 */ | |
| 68 void doneIndex(); | |
| 69 | |
| 70 /** | |
| 71 * Returns a [Future] that completes with locations of the elements that have | |
| 72 * the given [relationship] with the given [element]. | |
| 73 * | |
| 74 * For example, if the [element] represents a function and the relationship is | |
| 75 * the `is-invoked-by` relationship, then the returned locations will be all | |
| 76 * of the places where the function is invoked. | |
| 77 * | |
| 78 * [element] - the the [Element] that has the relationship with the locations | |
| 79 * to be returned. | |
| 80 * [relationship] - the [Relationship] between the given element and the | |
| 81 * locations to be returned | |
| 82 */ | |
| 83 Future<List<Location>> getRelationships(Element element, | |
| 84 Relationship relationship); | |
| 85 | |
| 86 /** | |
| 87 * Records that the given [element] and [location] have the given | |
| 88 * [relationship]. | |
| 89 * | |
| 90 * For example, if the [relationship] is the `is-invoked-by` relationship, | |
| 91 * then [element] would be the function being invoked and [location] would be | |
| 92 * the point at which it is referenced. Each element can have the same | |
| 93 * relationship with multiple locations. In other words, if the following code | |
| 94 * were executed | |
| 95 * | |
| 96 * recordRelationship(element, isReferencedBy, location1); | |
| 97 * recordRelationship(element, isReferencedBy, location2); | |
| 98 * | |
| 99 * then both relationships would be maintained in the index and the result of
executing | |
| 100 * | |
| 101 * getRelationship(element, isReferencedBy); | |
| 102 * | |
| 103 * would be a list containing both `location1` and `location2`. | |
| 104 * | |
| 105 * [element] - the [Element] that is related to the location. | |
| 106 * [relationship] - the [Relationship] between the element and the location. | |
| 107 * [location] the [Location] where relationship happens. | |
| 108 */ | |
| 109 void recordRelationship(Element element, Relationship relationship, | |
| 110 Location location); | |
| 111 | |
| 112 /** | |
| 113 * Removes from the index all of the information associated with [context]. | |
| 114 * | |
| 115 * This method should be invoked when [context] is disposed. | |
| 116 * | |
| 117 * [context] - the [AnalysisContext] being removed. | |
| 118 */ | |
| 119 void removeContext(AnalysisContext context); | |
| 120 | |
| 121 /** | |
| 122 * Removes from the index all of the information associated with elements or | |
| 123 * locations in [source]. This includes relationships between an element in | |
| 124 * [source] and any other locations, relationships between any other elements | |
| 125 * and locations within [source]. | |
| 126 * | |
| 127 * This method should be invoked when [source] is no longer part of the code | |
| 128 * base. | |
| 129 * | |
| 130 * [context] - the [AnalysisContext] in which [source] being removed. | |
| 131 * [source] - the [Source] being removed | |
| 132 */ | |
| 133 void removeSource(AnalysisContext context, Source source); | |
| 134 | |
| 135 /** | |
| 136 * Removes from the index all of the information associated with elements or | |
| 137 * locations in the given sources. This includes relationships between an | |
| 138 * element in the given sources and any other locations, relationships between | |
| 139 * any other elements and a location within the given sources. | |
| 140 * | |
| 141 * This method should be invoked when multiple sources are no longer part of | |
| 142 * the code base. | |
| 143 * | |
| 144 * [context] - the [AnalysisContext] in which [Source]s being removed. | |
| 145 * [container] - the [SourceContainer] holding the sources being removed. | |
| 146 */ | |
| 147 void removeSources(AnalysisContext context, SourceContainer container); | |
| 148 } | |
| OLD | NEW |