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

Unified Diff: pkg/analysis_server/test/index/store/memory_node_manager.dart

Issue 346963006: Index Dart/HTML units after analysis. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/index/store/memory_node_manager.dart
diff --git a/pkg/analysis_server/test/index/store/memory_node_manager.dart b/pkg/analysis_server/test/index/store/memory_node_manager.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3a9209e8d9b9d716d793547eabce3f58bd7344dc
--- /dev/null
+++ b/pkg/analysis_server/test/index/store/memory_node_manager.dart
@@ -0,0 +1,96 @@
+// 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 test.index.store_memory_node_manager;
+
+import 'dart:async';
+import 'dart:collection';
+
+import 'package:analysis_server/src/index/store/codec.dart';
+import 'package:analysis_server/src/index/store/split_store.dart';
+import 'package:analyzer/src/generated/engine.dart';
+
+
+class MemoryNodeManager implements NodeManager {
+ ContextCodec _contextCodec = new ContextCodec();
+ ElementCodec _elementCodec;
+ int _locationCount = 0;
+ final Map<String, int> _nodeLocationCounts = new HashMap<String, int>();
+ final Map<String, IndexNode> _nodes = new HashMap<String, IndexNode>();
+ RelationshipCodec _relationshipCodec;
+ StringCodec _stringCodec = new StringCodec();
+
+ MemoryNodeManager() {
+ _elementCodec = new ElementCodec(_stringCodec);
+ _relationshipCodec = new RelationshipCodec(_stringCodec);
+ }
+
+ @override
+ ContextCodec get contextCodec {
+ return _contextCodec;
+ }
+
+ @override
+ ElementCodec get elementCodec {
+ return _elementCodec;
+ }
+
+ @override
+ int get locationCount {
+ return _locationCount;
+ }
+
+ @override
+ StringCodec get stringCodec {
+ return _stringCodec;
+ }
+
+ @override
+ void clear() {
+ _nodes.clear();
+ }
+
+ int getLocationCount(String name) {
+ int locationCount = _nodeLocationCounts[name];
+ return locationCount != null ? locationCount : 0;
+ }
+
+ @override
+ Future<IndexNode> getNode(String name) {
+ return new Future.value(_nodes[name]);
+ }
+
+ bool isEmpty() {
+ for (IndexNode node in _nodes.values) {
+ Map<RelationKeyData, List<LocationData>> relations = node.relations;
+ if (!relations.isEmpty) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @override
+ IndexNode newNode(AnalysisContext context) {
+ return new IndexNode(context, elementCodec, _relationshipCodec);
+ }
+
+ @override
+ void putNode(String name, IndexNode node) {
+ // update location count
+ {
+ _locationCount -= getLocationCount(name);
+ int nodeLocationCount = node.locationCount;
+ _nodeLocationCounts[name] = nodeLocationCount;
+ _locationCount += nodeLocationCount;
+ }
+ // remember the node
+ _nodes[name] = node;
+ }
+
+ @override
+ void removeNode(String name) {
+ _nodes.remove(name);
+ }
+}
« no previous file with comments | « pkg/analysis_server/test/index/index_test.dart ('k') | pkg/analysis_server/test/index/store/split_store_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698