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.src.index.local_index; | |
6 | |
7 import 'dart:async'; | |
8 | |
9 import 'package:analysis_services/index/index.dart'; | |
10 import 'package:analysis_services/src/index/index_contributor.dart' as contribut
ors; | |
11 import 'package:analysis_services/src/index/store/split_store.dart'; | |
12 import 'package:analyzer/src/generated/ast.dart'; | |
13 import 'package:analyzer/src/generated/element.dart'; | |
14 import 'package:analyzer/src/generated/engine.dart'; | |
15 import 'package:analyzer/src/generated/html.dart'; | |
16 import 'package:analyzer/src/generated/source.dart'; | |
17 | |
18 | |
19 /** | |
20 * A local implementation of [Index]. | |
21 */ | |
22 class LocalIndex extends Index { | |
23 SplitIndexStore _store; | |
24 | |
25 LocalIndex(NodeManager nodeManager) { | |
26 _store = new SplitIndexStore(nodeManager); | |
27 } | |
28 | |
29 @override | |
30 String get statistics => _store.statistics; | |
31 | |
32 @override | |
33 void clear() { | |
34 _store.clear(); | |
35 } | |
36 | |
37 /** | |
38 * Returns a `Future<List<Location>>` that completes with the list of | |
39 * [Location]s of the given [relationship] with the given [element]. | |
40 * | |
41 * For example, if the [element] represents a function and the [relationship] | |
42 * is the `is-invoked-by` relationship, then the locations will be all of the | |
43 * places where the function is invoked. | |
44 */ | |
45 @override | |
46 Future<List<Location>> getRelationships(Element element, | |
47 Relationship relationship) { | |
48 return _store.getRelationships(element, relationship); | |
49 } | |
50 | |
51 @override | |
52 void indexHtmlUnit(AnalysisContext context, HtmlUnit unit) { | |
53 contributors.indexHtmlUnit(_store, context, unit); | |
54 } | |
55 | |
56 @override | |
57 void indexUnit(AnalysisContext context, CompilationUnit unit) { | |
58 contributors.indexDartUnit(_store, context, unit); | |
59 } | |
60 | |
61 @override | |
62 void removeContext(AnalysisContext context) { | |
63 _store.removeContext(context); | |
64 } | |
65 | |
66 @override | |
67 void removeSource(AnalysisContext context, Source source) { | |
68 _store.removeSource(context, source); | |
69 } | |
70 | |
71 @override | |
72 void removeSources(AnalysisContext context, SourceContainer container) { | |
73 _store.removeSources(context, container); | |
74 } | |
75 | |
76 @override | |
77 void run() { | |
78 // NO-OP for the local index | |
79 } | |
80 | |
81 @override | |
82 void stop() { | |
83 // NO-OP for the local index | |
84 } | |
85 } | |
OLD | NEW |