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

Unified Diff: pkg/analysis_server/test/services/index/store/split_store_test.dart

Issue 971833003: Optimize top-level element declarations search. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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/services/index/store/split_store_test.dart
diff --git a/pkg/analysis_server/test/services/index/store/split_store_test.dart b/pkg/analysis_server/test/services/index/store/split_store_test.dart
index 6a8bacbeb92b2b0921f9c8e927ed065684334d9f..c1a1a0b4093b648d77b137f025c0f3f2ba09ab21 100644
--- a/pkg/analysis_server/test/services/index/store/split_store_test.dart
+++ b/pkg/analysis_server/test/services/index/store/split_store_test.dart
@@ -913,186 +913,141 @@ class _SplitIndexStoreTest {
store.removeSources(null, null);
}
- test_removeSources_unit() {
- Location locationA = mockLocation(elementA);
- Location locationB = mockLocation(elementB);
- Location locationC = mockLocation(elementC);
+ void test_removeSources_unit() {
{
store.aboutToIndexDart(contextA, unitElementA);
- store.recordRelationship(elementA, relationship, locationA);
+ store.recordTopDeclaration(elementA);
store.doneIndex();
}
{
store.aboutToIndexDart(contextA, unitElementB);
- store.recordRelationship(elementA, relationship, locationB);
+ store.recordTopDeclaration(elementB);
store.doneIndex();
}
{
store.aboutToIndexDart(contextA, unitElementC);
- store.recordRelationship(elementA, relationship, locationC);
+ store.recordTopDeclaration(elementC);
store.doneIndex();
}
- // "A", "B" and "C" locations
- return store.getRelationships(
- elementA,
- relationship).then((List<Location> locations) {
- assertLocations(locations, [locationA, locationB, locationC]);
- }).then((_) {
- // remove "A" source
- store.removeSources(contextA, new SingleSourceContainer(sourceA));
- store.removeSource(contextA, sourceA);
- return store.getRelationships(
- elementA,
- relationship).then((List<Location> locations) {
- assertLocations(locations, [locationB, locationC]);
- });
- });
+ // A, B, C elements
+ {
+ List<Element> elements = store.getTopDeclarations((_) => true);
+ expect(elements, unorderedEquals([elementA, elementB, elementC]));
+ }
+ // remove "A" source
+ store.removeSources(contextA, new SingleSourceContainer(sourceA));
+ store.removeSource(contextA, sourceA);
+ {
+ List<Element> elements = store.getTopDeclarations((_) => true);
+ expect(elements, unorderedEquals([elementB, elementC]));
+ }
}
- test_universe_aboutToIndex() {
+ void test_universe_aboutToIndex() {
when(contextA.getElement(elementLocationA)).thenReturn(elementA);
when(contextB.getElement(elementLocationB)).thenReturn(elementB);
- Location locationA = mockLocation(elementA);
- Location locationB = mockLocation(elementB);
{
store.aboutToIndexDart(contextA, unitElementA);
- store.recordRelationship(
- UniverseElement.INSTANCE,
- relationship,
- locationA);
+ store.recordTopDeclaration(elementA);
store.doneIndex();
}
{
store.aboutToIndexDart(contextB, unitElementB);
- store.recordRelationship(
- UniverseElement.INSTANCE,
- relationship,
- locationB);
+ store.recordTopDeclaration(elementB);
store.doneIndex();
}
- // get relationships
- return store.getRelationships(
- UniverseElement.INSTANCE,
- relationship).then((List<Location> locations) {
- assertLocations(locations, [locationA, locationB]);
- }).then((_) {
+ // elementA, elementB
+ {
+ List<Element> elements = store.getTopDeclarations((_) => true);
+ expect(elements, unorderedEquals([elementA, elementB]));
+ }
// re-index "unitElementA"
+ {
store.aboutToIndexDart(contextA, unitElementA);
store.doneIndex();
- return store.getRelationships(
- UniverseElement.INSTANCE,
- relationship).then((List<Location> locations) {
- assertLocations(locations, [locationB]);
- });
- });
+ }
+ {
+ List<Element> elements = store.getTopDeclarations((_) => true);
+ expect(elements, unorderedEquals([elementB]));
+ }
}
- test_universe_clear() {
+ void test_universe_clear() {
when(contextA.getElement(elementLocationA)).thenReturn(elementA);
when(contextB.getElement(elementLocationB)).thenReturn(elementB);
- Location locationA = mockLocation(elementA);
- Location locationB = mockLocation(elementB);
{
store.aboutToIndexDart(contextA, unitElementA);
- store.recordRelationship(
- UniverseElement.INSTANCE,
- relationship,
- locationA);
+ store.recordTopDeclaration(elementA);
store.doneIndex();
}
{
- store.aboutToIndexDart(contextA, unitElementB);
- store.recordRelationship(
- UniverseElement.INSTANCE,
- relationship,
- locationB);
+ store.aboutToIndexDart(contextB, unitElementB);
+ store.recordTopDeclaration(elementB);
store.doneIndex();
}
- return store.getRelationships(
- UniverseElement.INSTANCE,
- relationship).then((List<Location> locations) {
- assertLocations(locations, [locationA, locationB]);
- }).then((_) {
- // clear
- store.clear();
- return store.getRelationships(
- UniverseElement.INSTANCE,
- relationship).then((List<Location> locations) {
- expect(locations, isEmpty);
- });
- });
+ // elementA, elementB
+ {
+ List<Element> elements = store.getTopDeclarations((_) => true);
+ expect(elements, unorderedEquals([elementA, elementB]));
+ }
+ // clear
+ store.clear();
+ {
+ List<Element> elements = store.getTopDeclarations((_) => true);
+ expect(elements, isEmpty);
+ }
}
- test_universe_removeContext() {
+ void test_universe_removeContext() {
when(contextA.getElement(elementLocationA)).thenReturn(elementA);
when(contextB.getElement(elementLocationB)).thenReturn(elementB);
- Location locationA = mockLocation(elementA);
- Location locationB = mockLocation(elementB);
{
store.aboutToIndexDart(contextA, unitElementA);
- store.recordRelationship(
- UniverseElement.INSTANCE,
- relationship,
- locationA);
+ store.recordTopDeclaration(elementA);
store.doneIndex();
}
{
store.aboutToIndexDart(contextB, unitElementB);
- store.recordRelationship(
- UniverseElement.INSTANCE,
- relationship,
- locationB);
+ store.recordTopDeclaration(elementB);
store.doneIndex();
}
- return store.getRelationships(
- UniverseElement.INSTANCE,
- relationship).then((List<Location> locations) {
- assertLocations(locations, [locationA, locationB]);
- }).then((_) {
- // remove "contextA"
- store.removeContext(contextA);
- return store.getRelationships(
- UniverseElement.INSTANCE,
- relationship).then((List<Location> locations) {
- assertLocations(locations, [locationB]);
- });
- });
+ // elementA, elementB
+ {
+ List<Element> elements = store.getTopDeclarations((_) => true);
+ expect(elements, unorderedEquals([elementA, elementB]));
+ }
+ // remove "contextA"
+ store.removeContext(contextA);
+ {
+ List<Element> elements = store.getTopDeclarations((_) => true);
+ expect(elements, unorderedEquals([elementB]));
+ }
}
- test_universe_removeSource() {
+ void test_universe_removeSource() {
when(contextA.getElement(elementLocationA)).thenReturn(elementA);
when(contextB.getElement(elementLocationB)).thenReturn(elementB);
- Location locationA = mockLocation(elementA);
- Location locationB = mockLocation(elementB);
{
store.aboutToIndexDart(contextA, unitElementA);
- store.recordRelationship(
- UniverseElement.INSTANCE,
- relationship,
- locationA);
+ store.recordTopDeclaration(elementA);
store.doneIndex();
}
{
- store.aboutToIndexDart(contextA, unitElementB);
- store.recordRelationship(
- UniverseElement.INSTANCE,
- relationship,
- locationB);
+ store.aboutToIndexDart(contextB, unitElementB);
+ store.recordTopDeclaration(elementB);
store.doneIndex();
}
- return store.getRelationships(
- UniverseElement.INSTANCE,
- relationship).then((List<Location> locations) {
- assertLocations(locations, [locationA, locationB]);
- }).then((_) {
- // remove "sourceA"
- store.removeSource(contextA, sourceA);
- return store.getRelationships(
- UniverseElement.INSTANCE,
- relationship).then((List<Location> locations) {
- assertLocations(locations, [locationB]);
- });
- });
+ // elementA, elementB
+ {
+ List<Element> elements = store.getTopDeclarations((_) => true);
+ expect(elements, unorderedEquals([elementA, elementB]));
+ }
+ // remove "sourceA"
+ store.removeSource(contextA, sourceA);
+ {
+ List<Element> elements = store.getTopDeclarations((_) => true);
+ expect(elements, unorderedEquals([elementB]));
+ }
}
/**

Powered by Google App Engine
This is Rietveld 408576698