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

Side by Side Diff: pkg/analyzer/lib/src/index/local_index.dart

Issue 375693002: Move index/search to services. (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 engine.src.index.local_index;
6
7 import 'dart:async';
8 import 'dart:io';
9
10 import 'package:analyzer/index/index.dart';
11 import 'package:analyzer/src/generated/ast.dart';
12 import 'package:analyzer/src/generated/element.dart';
13 import 'package:analyzer/src/generated/engine.dart';
14 import 'package:analyzer/src/generated/html.dart';
15 import 'package:analyzer/src/generated/source.dart';
16 import 'package:analyzer/src/index/index_contributor.dart' as contributors;
17 import 'package:analyzer/src/index/store/codec.dart';
18 import 'package:analyzer/src/index/store/memory_node_manager.dart';
19 import 'package:analyzer/src/index/store/separate_file_manager.dart';
20 import 'package:analyzer/src/index/store/split_store.dart';
21
22
23 Index createLocalFileSplitIndex(Directory directory) {
24 var fileManager = new SeparateFileManager(directory);
25 var stringCodec = new StringCodec();
26 var nodeManager = new FileNodeManager(fileManager,
27 AnalysisEngine.instance.logger, stringCodec, new ContextCodec(),
28 new ElementCodec(stringCodec), new RelationshipCodec(stringCodec));
29 return new LocalIndex(nodeManager);
30 }
31
32
33 Index createLocalMemorySplitIndex() {
34 return new LocalIndex(new MemoryNodeManager());
35 }
36
37
38 /**
39 * A local implementation of [Index].
40 */
41 class LocalIndex extends Index {
42 SplitIndexStore _store;
43
44 LocalIndex(NodeManager nodeManager) {
45 _store = new SplitIndexStore(nodeManager);
46 }
47
48 @override
49 String get statistics => _store.statistics;
50
51 @override
52 void clear() {
53 _store.clear();
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 @override
65 Future<List<Location>> getRelationships(Element element,
66 Relationship relationship) {
67 return _store.getRelationships(element, relationship);
68 }
69
70 @override
71 void indexHtmlUnit(AnalysisContext context, HtmlUnit unit) {
72 contributors.indexHtmlUnit(_store, context, unit);
73 }
74
75 @override
76 void indexUnit(AnalysisContext context, CompilationUnit unit) {
77 contributors.indexDartUnit(_store, context, unit);
78 }
79
80 @override
81 void removeContext(AnalysisContext context) {
82 _store.removeContext(context);
83 }
84
85 @override
86 void removeSource(AnalysisContext context, Source source) {
87 _store.removeSource(context, source);
88 }
89
90 @override
91 void removeSources(AnalysisContext context, SourceContainer container) {
92 _store.removeSources(context, container);
93 }
94
95 @override
96 void run() {
97 // NO-OP for the local index
98 }
99
100 @override
101 void stop() {
102 // NO-OP for the local index
103 }
104 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/index/index_contributor.dart ('k') | pkg/analyzer/lib/src/index/store/codec.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698