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

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

Issue 351813002: A local file-based Index implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweaks 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
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/index/store/split_store.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /**
22 * An implementation of [Index] with [SplitIndexStore].
23 */
24 class LocalSplitIndex extends Index {
25 SplitIndexStore _store;
26
27 LocalSplitIndex(Directory directory) {
28 var fileManager = new SeparateFileManager(directory);
29 var stringCodec = new StringCodec();
30 var nodeManager = new FileNodeManager(fileManager,
31 AnalysisEngine.instance.logger, stringCodec, new ContextCodec(),
32 new ElementCodec(stringCodec), new RelationshipCodec(stringCodec));
33 _store = new SplitIndexStore(nodeManager);
34 }
35
36 @override
37 String get statistics => _store.statistics;
38
39 @override
40 void clear() {
41 _store.clear();
42 }
43
44 @override
45 void getRelationships(Element element, Relationship relationship,
46 RelationshipCallback callback) {
47 // TODO(scheglov) update Index API to use asynchronous interface
48 callback.hasRelationships(element, relationship, Location.EMPTY_ARRAY);
49 }
50
51 /**
52 * Returns a `Future<List<Location>>` that completes with the list of
53 * [Location]s of the given [relationship] with the given [element].
54 *
55 * For example, if the [element] represents a function and the [relationship]
56 * is the `is-invoked-by` relationship, then the locations will be all of the
57 * places where the function is invoked.
58 */
59 Future<List<Location>> getRelationshipsAsync(Element element,
60 Relationship relationship) {
61 return _store.getRelationshipsAsync(element, relationship);
62 }
63
64 @override
65 void indexHtmlUnit(AnalysisContext context, HtmlUnit unit) {
66 if (unit == null) {
67 return;
68 }
69 if (unit.element == null) {
70 return;
71 }
72 new IndexHtmlUnitOperation(_store, context, unit).performOperation();
73 }
74
75 @override
76 void indexUnit(AnalysisContext context, CompilationUnit unit) {
77 if (unit == null) {
78 return;
79 }
80 if (unit.element == null) {
81 return;
82 }
83 new IndexUnitOperation(_store, context, unit).performOperation();
84 }
85
86 @override
87 void removeContext(AnalysisContext context) {
88 _store.removeContext(context);
89 }
90
91 @override
92 void removeSource(AnalysisContext context, Source source) {
93 _store.removeSource(context, source);
94 }
95
96 @override
97 void removeSources(AnalysisContext context, SourceContainer container) {
98 _store.removeSources(context, container);
99 }
100
101 @override
102 void run() {
103 // NO-OP if in the same isolate
104 }
105
106 @override
107 void stop() {
108 // NO-OP if in the same isolate
109 }
110 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/index/store/split_store.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698