Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: pkg/analysis_server/lib/src/index/index.dart

Issue 365193004: Move Index and IndexStore implementations into Engine. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 index;
6
7 import 'dart:async';
8 import 'dart:io';
9
10 import 'package:analysis_server/src/index/store/codec.dart';
11 import 'package:analysis_server/src/index/store/separate_file_manager.dart';
12 import 'package:analysis_server/src/index/store/split_store.dart';
13 import 'package:analyzer/src/generated/ast.dart';
14 import 'package:analyzer/src/generated/element.dart';
15 import 'package:analyzer/src/generated/engine.dart';
16 import 'package:analyzer/src/generated/html.dart';
17 import 'package:analyzer/src/generated/index.dart';
18 import 'package:analyzer/src/generated/source.dart';
19
20
21 Index createLocalFileSplitIndex(Directory directory) {
22 var fileManager = new SeparateFileManager(directory);
23 var stringCodec = new StringCodec();
24 var nodeManager = new FileNodeManager(fileManager,
25 AnalysisEngine.instance.logger, stringCodec, new ContextCodec(),
26 new ElementCodec(stringCodec), new RelationshipCodec(stringCodec));
27 return new LocalIndex(nodeManager);
28 }
29
30
31 /**
32 * A local implementation of [Index].
33 */
34 class LocalIndex extends Index {
35 SplitIndexStore _store;
36
37 LocalIndex(NodeManager nodeManager) {
38 _store = new SplitIndexStore(nodeManager);
39 }
40
41 @override
42 String get statistics => _store.statistics;
43
44 @override
45 void clear() {
46 _store.clear();
47 }
48
49 @override
50 void getRelationships(Element element, Relationship relationship,
51 RelationshipCallback callback) {
52 // TODO(scheglov) update Index API to use asynchronous interface
53 callback.hasRelationships(element, relationship, Location.EMPTY_ARRAY);
54 }
55
56 /**
57 * Returns a `Future<List<Location>>` that completes with the list of
58 * [Location]s of the given [relationship] with the given [element].
59 *
60 * For example, if the [element] represents a function and the [relationship]
61 * is the `is-invoked-by` relationship, then the locations will be all of the
62 * places where the function is invoked.
63 */
64 Future<List<Location>> getRelationshipsAsync(Element element,
65 Relationship relationship) {
66 return _store.getRelationshipsAsync(element, relationship);
67 }
68
69 @override
70 void indexHtmlUnit(AnalysisContext context, HtmlUnit unit) {
71 if (unit == null) {
72 return;
73 }
74 if (unit.element == null) {
75 return;
76 }
77 new IndexHtmlUnitOperation(_store, context, unit).performOperation();
78 }
79
80 @override
81 void indexUnit(AnalysisContext context, CompilationUnit unit) {
82 if (unit == null) {
83 return;
84 }
85 if (unit.element == null) {
86 return;
87 }
88 new IndexUnitOperation(_store, context, unit).performOperation();
89 }
90
91 @override
92 void removeContext(AnalysisContext context) {
93 _store.removeContext(context);
94 }
95
96 @override
97 void removeSource(AnalysisContext context, Source source) {
98 _store.removeSource(context, source);
99 }
100
101 @override
102 void removeSources(AnalysisContext context, SourceContainer container) {
103 _store.removeSources(context, container);
104 }
105
106 @override
107 void run() {
108 // NO-OP if in the same isolate
109 }
110
111 @override
112 void stop() {
113 // NO-OP if in the same isolate
114 }
115 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698