| Index: pkg/analysis_server/test/index/store/split_store_test.dart
|
| diff --git a/pkg/analysis_server/test/index/store/split_store_test.dart b/pkg/analysis_server/test/index/store/split_store_test.dart
|
| index 39c134ac9c55cc2681e149a93b66b972e17b341f..cc1b5c1114806012db66a2164c5eea8dd94d8414 100644
|
| --- a/pkg/analysis_server/test/index/store/split_store_test.dart
|
| +++ b/pkg/analysis_server/test/index/store/split_store_test.dart
|
| @@ -5,7 +5,6 @@
|
| library test.index.split_store;
|
|
|
| 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';
|
| @@ -17,6 +16,7 @@ import 'package:typed_mock/typed_mock.dart';
|
| import 'package:unittest/unittest.dart';
|
|
|
| import '../../reflective_tests.dart';
|
| +import 'memory_node_manager.dart';
|
| import 'single_source_container.dart';
|
| import 'typed_mocks.dart';
|
|
|
| @@ -402,90 +402,6 @@ class _LocationEqualsWrapper {
|
| }
|
|
|
|
|
| -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);
|
| - }
|
| -}
|
| -
|
| -
|
| class _MockFileManager extends TypedMock implements FileManager {
|
| noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
| }
|
| @@ -570,7 +486,7 @@ class _SplitIndexStoreTest {
|
| LibraryElement libraryElement = new MockLibraryElement();
|
| Source librarySource = new MockSource('librarySource');
|
| CompilationUnitElement libraryUnitElement = new MockCompilationUnitElement();
|
| - _MemoryNodeManager nodeManager = new _MemoryNodeManager();
|
| + MemoryNodeManager nodeManager = new MemoryNodeManager();
|
| Relationship relationship = Relationship.getRelationship('test-relationship');
|
| Source sourceA = new MockSource('sourceA');
|
| Source sourceB = new MockSource('sourceB');
|
| @@ -1026,7 +942,7 @@ class _SplitIndexStoreTest {
|
| });
|
| }
|
|
|
| - test_universe_removeContext() {
|
| + test_universe_clear() {
|
| when(contextA.getElement(elementLocationA)).thenReturn(elementA);
|
| when(contextB.getElement(elementLocationB)).thenReturn(elementB);
|
| Location locationA = mockLocation(elementA);
|
| @@ -1038,7 +954,7 @@ class _SplitIndexStoreTest {
|
| store.doneIndex();
|
| }
|
| {
|
| - store.aboutToIndexDart(contextB, unitElementB);
|
| + store.aboutToIndexDart(contextA, unitElementB);
|
| store.recordRelationship(UniverseElement.INSTANCE, relationship,
|
| locationB);
|
| store.doneIndex();
|
| @@ -1047,16 +963,16 @@ class _SplitIndexStoreTest {
|
| relationship).then((List<Location> locations) {
|
| assertLocations(locations, [locationA, locationB]);
|
| }).then((_) {
|
| - // remove "contextA"
|
| - store.removeContext(contextA);
|
| + // clear
|
| + store.clear();
|
| return store.getRelationshipsAsync(UniverseElement.INSTANCE,
|
| relationship).then((List<Location> locations) {
|
| - assertLocations(locations, [locationB]);
|
| + expect(locations, isEmpty);
|
| });
|
| });
|
| }
|
|
|
| - test_universe_removeSource() {
|
| + test_universe_removeContext() {
|
| when(contextA.getElement(elementLocationA)).thenReturn(elementA);
|
| when(contextB.getElement(elementLocationB)).thenReturn(elementB);
|
| Location locationA = mockLocation(elementA);
|
| @@ -1068,7 +984,7 @@ class _SplitIndexStoreTest {
|
| store.doneIndex();
|
| }
|
| {
|
| - store.aboutToIndexDart(contextA, unitElementB);
|
| + store.aboutToIndexDart(contextB, unitElementB);
|
| store.recordRelationship(UniverseElement.INSTANCE, relationship,
|
| locationB);
|
| store.doneIndex();
|
| @@ -1077,8 +993,8 @@ class _SplitIndexStoreTest {
|
| relationship).then((List<Location> locations) {
|
| assertLocations(locations, [locationA, locationB]);
|
| }).then((_) {
|
| - // remove "sourceA"
|
| - store.removeSource(contextA, sourceA);
|
| + // remove "contextA"
|
| + store.removeContext(contextA);
|
| return store.getRelationshipsAsync(UniverseElement.INSTANCE,
|
| relationship).then((List<Location> locations) {
|
| assertLocations(locations, [locationB]);
|
| @@ -1086,7 +1002,7 @@ class _SplitIndexStoreTest {
|
| });
|
| }
|
|
|
| - test_universe_clear() {
|
| + test_universe_removeSource() {
|
| when(contextA.getElement(elementLocationA)).thenReturn(elementA);
|
| when(contextB.getElement(elementLocationB)).thenReturn(elementB);
|
| Location locationA = mockLocation(elementA);
|
| @@ -1107,11 +1023,11 @@ class _SplitIndexStoreTest {
|
| relationship).then((List<Location> locations) {
|
| assertLocations(locations, [locationA, locationB]);
|
| }).then((_) {
|
| - // clear
|
| - store.clear();
|
| + // remove "sourceA"
|
| + store.removeSource(contextA, sourceA);
|
| return store.getRelationshipsAsync(UniverseElement.INSTANCE,
|
| relationship).then((List<Location> locations) {
|
| - expect(locations, isEmpty);
|
| + assertLocations(locations, [locationB]);
|
| });
|
| });
|
| }
|
|
|