Chromium Code Reviews| Index: pkg/analysis_server/lib/src/index/index.dart |
| diff --git a/pkg/analysis_server/lib/src/index/index.dart b/pkg/analysis_server/lib/src/index/index.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..622e809d1cc2815bea434b962cd3cd59db253cdb |
| --- /dev/null |
| +++ b/pkg/analysis_server/lib/src/index/index.dart |
| @@ -0,0 +1,102 @@ |
| +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library index; |
| + |
| +import 'dart:async'; |
| +import 'dart:io'; |
| + |
| +import 'package:analysis_server/src/index/store/codec.dart'; |
| +import 'package:analysis_server/src/index/store/separate_file_manager.dart'; |
| +import 'package:analysis_server/src/index/store/split_store.dart'; |
| +import 'package:analyzer/src/generated/ast.dart'; |
| +import 'package:analyzer/src/generated/element.dart'; |
| +import 'package:analyzer/src/generated/engine.dart'; |
| +import 'package:analyzer/src/generated/html.dart'; |
| +import 'package:analyzer/src/generated/index.dart'; |
| +import 'package:analyzer/src/generated/source.dart'; |
| + |
| + |
| +/** |
| + * An implementation of [Index] with [SplitIndexStore]. |
| + */ |
| +class LocalSplitIndex extends Index { |
| + SplitIndexStore _store; |
| + |
| + LocalSplitIndex(Directory directory) { |
| + var fileManager = new SeparateFileManager(directory); |
| + var stringCodec = new StringCodec(); |
| + var nodeManager = new FileNodeManager(fileManager, |
| + AnalysisEngine.instance.logger, stringCodec, new ContextCodec(), |
| + new ElementCodec(stringCodec), new RelationshipCodec(stringCodec)); |
| + _store = new SplitIndexStore(nodeManager); |
| + } |
| + |
| + @override |
| + String get statistics => _store.statistics; |
| + |
| + @override |
| + void clear() { |
| + _store.clear(); |
| + } |
| + |
| + @override |
| + void getRelationships(Element element, Relationship relationship, |
| + RelationshipCallback callback) { |
| + // TODO(scheglov) update Index API to use asynchronous interface |
| + callback.hasRelationships(element, relationship, Location.EMPTY_ARRAY); |
| + } |
| + |
| + 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
|
| + Relationship relationship) { |
| + return _store.getRelationshipsAsync(element, relationship); |
| + } |
| + |
| + @override |
| + void indexHtmlUnit(AnalysisContext context, HtmlUnit unit) { |
| + if (unit == null) { |
| + return; |
| + } |
| + if (unit.element == null) { |
| + return; |
| + } |
| + new IndexHtmlUnitOperation(_store, context, unit).performOperation(); |
| + } |
| + |
| + @override |
| + void indexUnit(AnalysisContext context, CompilationUnit unit) { |
| + if (unit == null) { |
| + return; |
| + } |
| + if (unit.element == null) { |
| + return; |
| + } |
| + new IndexUnitOperation(_store, context, unit).performOperation(); |
| + } |
| + |
| + @override |
| + void removeContext(AnalysisContext context) { |
| + _store.removeContext(context); |
| + } |
| + |
| + @override |
| + void removeSource(AnalysisContext context, Source source) { |
| + _store.removeSource(context, source); |
| + } |
| + |
| + @override |
| + void removeSources(AnalysisContext context, SourceContainer container) { |
| + _store.removeSources(context, container); |
| + } |
| + |
| + @override |
| + void run() { |
| + // NO-OP if in the same isolate |
| + } |
| + |
| + @override |
| + void stop() { |
| + // NO-OP if in the same isolate |
| + } |
| +} |