Index: pkg/analyzer/lib/src/index/local_index.dart |
diff --git a/pkg/analysis_server/lib/src/index/index.dart b/pkg/analyzer/lib/src/index/local_index.dart |
similarity index 67% |
rename from pkg/analysis_server/lib/src/index/index.dart |
rename to pkg/analyzer/lib/src/index/local_index.dart |
index 023cfc9c2f4ea9d913be0110770e31a77c9b22d9..08e035d59fc1908c56daa4930283acff878690d4 100644 |
--- a/pkg/analysis_server/lib/src/index/index.dart |
+++ b/pkg/analyzer/lib/src/index/local_index.dart |
@@ -2,20 +2,22 @@ |
// 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; |
+library engine.src.index.local_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/index/index.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'; |
+import 'package:analyzer/src/index/index_contributor.dart' as contributors; |
+import 'package:analyzer/src/index/store/codec.dart'; |
+import 'package:analyzer/src/index/store/memory_node_manager.dart'; |
+import 'package:analyzer/src/index/store/separate_file_manager.dart'; |
+import 'package:analyzer/src/index/store/split_store.dart'; |
Index createLocalFileSplitIndex(Directory directory) { |
@@ -28,6 +30,11 @@ Index createLocalFileSplitIndex(Directory directory) { |
} |
+Index createLocalMemorySplitIndex() { |
+ return new LocalIndex(new MemoryNodeManager()); |
+} |
+ |
+ |
/** |
* A local implementation of [Index]. |
*/ |
@@ -46,13 +53,6 @@ class LocalIndex extends Index { |
_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); |
- } |
- |
/** |
* Returns a `Future<List<Location>>` that completes with the list of |
* [Location]s of the given [relationship] with the given [element]. |
@@ -61,31 +61,20 @@ class LocalIndex extends Index { |
* is the `is-invoked-by` relationship, then the locations will be all of the |
* places where the function is invoked. |
*/ |
- Future<List<Location>> getRelationshipsAsync(Element element, |
+ @override |
+ Future<List<Location>> getRelationships(Element element, |
Relationship relationship) { |
- return _store.getRelationshipsAsync(element, relationship); |
+ return _store.getRelationships(element, relationship); |
} |
@override |
void indexHtmlUnit(AnalysisContext context, HtmlUnit unit) { |
- if (unit == null) { |
- return; |
- } |
- if (unit.element == null) { |
- return; |
- } |
- new IndexHtmlUnitOperation(_store, context, unit).performOperation(); |
+ contributors.indexHtmlUnit(_store, context, unit); |
} |
@override |
void indexUnit(AnalysisContext context, CompilationUnit unit) { |
- if (unit == null) { |
- return; |
- } |
- if (unit.element == null) { |
- return; |
- } |
- new IndexUnitOperation(_store, context, unit).performOperation(); |
+ contributors.indexDartUnit(_store, context, unit); |
} |
@override |
@@ -105,11 +94,11 @@ class LocalIndex extends Index { |
@override |
void run() { |
- // NO-OP if in the same isolate |
+ // NO-OP for the local index |
} |
@override |
void stop() { |
- // NO-OP if in the same isolate |
+ // NO-OP for the local index |
} |
} |