Chromium Code Reviews| 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 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 Future<List<Location>> getRelationshipsAsync(Element element, | |
|
Brian Wilkerson
2014/06/24 13:53:41
You should double check, but I believe that the co
scheglov
2014/06/24 15:21:22
I have to implementIndex interface as is for now.
Paul Berry
2014/06/24 15:49:59
I agree in principle, however since the synchronou
| |
| 52 Relationship relationship) { | |
| 53 return _store.getRelationshipsAsync(element, relationship); | |
| 54 } | |
| 55 | |
| 56 @override | |
| 57 void indexHtmlUnit(AnalysisContext context, HtmlUnit unit) { | |
| 58 if (unit == null) { | |
| 59 return; | |
| 60 } | |
| 61 if (unit.element == null) { | |
| 62 return; | |
| 63 } | |
| 64 new IndexHtmlUnitOperation(_store, context, unit).performOperation(); | |
| 65 } | |
| 66 | |
| 67 @override | |
| 68 void indexUnit(AnalysisContext context, CompilationUnit unit) { | |
| 69 if (unit == null) { | |
| 70 return; | |
| 71 } | |
| 72 if (unit.element == null) { | |
| 73 return; | |
| 74 } | |
| 75 new IndexUnitOperation(_store, context, unit).performOperation(); | |
| 76 } | |
| 77 | |
| 78 @override | |
| 79 void removeContext(AnalysisContext context) { | |
| 80 _store.removeContext(context); | |
| 81 } | |
| 82 | |
| 83 @override | |
| 84 void removeSource(AnalysisContext context, Source source) { | |
| 85 _store.removeSource(context, source); | |
| 86 } | |
| 87 | |
| 88 @override | |
| 89 void removeSources(AnalysisContext context, SourceContainer container) { | |
| 90 _store.removeSources(context, container); | |
| 91 } | |
| 92 | |
| 93 @override | |
| 94 void run() { | |
| 95 // NO-OP if in the same isolate | |
| 96 } | |
| 97 | |
| 98 @override | |
| 99 void stop() { | |
| 100 // NO-OP if in the same isolate | |
| 101 } | |
| 102 } | |
| OLD | NEW |