| Index: pkg/analysis_server/test/services/index/local_index_test.dart
|
| diff --git a/pkg/analysis_server/test/services/index/local_index_test.dart b/pkg/analysis_server/test/services/index/local_index_test.dart
|
| index 558b2262ee82253eeec50eb686a06847b40eecf3..335d238378a3cd4e19a28a4b5c6ae63ada22fa78 100644
|
| --- a/pkg/analysis_server/test/services/index/local_index_test.dart
|
| +++ b/pkg/analysis_server/test/services/index/local_index_test.dart
|
| @@ -4,12 +4,10 @@
|
|
|
| library test.services.src.index.local_index;
|
|
|
| -import 'dart:async';
|
| -
|
| -import 'package:analysis_server/src/services/index/index.dart';
|
| import 'package:analysis_server/src/services/index/local_index.dart';
|
| import 'package:analysis_server/src/services/index/local_memory_index.dart';
|
| import 'package:analyzer/src/generated/ast.dart';
|
| +import 'package:analyzer/src/generated/element.dart';
|
| import 'package:analyzer/src/generated/html.dart';
|
| import 'package:analyzer/src/generated/source_io.dart';
|
| import 'package:unittest/unittest.dart';
|
| @@ -25,13 +23,13 @@ main() {
|
| }
|
|
|
|
|
| -void _assertElementNames(List<Location> locations, List expected) {
|
| - expect(_toElementNames(locations), unorderedEquals(expected));
|
| +void _assertElementNames(List<Element> elements, List expected) {
|
| + expect(_toElementNames(elements), unorderedEquals(expected));
|
| }
|
|
|
|
|
| -Iterable<String> _toElementNames(List<Location> locations) {
|
| - return locations.map((loc) => loc.element.name);
|
| +Iterable<String> _toElementNames(List<Element> elements) {
|
| + return elements.map((element) => element.name);
|
| }
|
|
|
|
|
| @@ -49,16 +47,12 @@ class LocalIndexTest extends AbstractContextTest {
|
| index = null;
|
| }
|
|
|
| - Future test_clear() {
|
| + void test_clear() {
|
| _indexTest('main() {}');
|
| - return _getDefinedFunctions().then((locations) {
|
| - _assertElementNames(locations, ['main']);
|
| + _assertElementNames(_getTopElements(), ['main']);
|
| // clear
|
| - index.clear();
|
| - return _getDefinedFunctions().then((locations) {
|
| - expect(locations, isEmpty);
|
| - });
|
| - });
|
| + index.clear();
|
| + expect(_getTopElements(), isEmpty);
|
| }
|
|
|
| void test_indexHtmlUnit_nullUnit() {
|
| @@ -70,11 +64,9 @@ class LocalIndexTest extends AbstractContextTest {
|
| index.indexHtmlUnit(context, unit);
|
| }
|
|
|
| - Future test_indexUnit() {
|
| + void test_indexUnit() {
|
| _indexTest('main() {}');
|
| - return _getDefinedFunctions().then((locations) {
|
| - _assertElementNames(locations, ['main']);
|
| - });
|
| + _assertElementNames(_getTopElements(), ['main']);
|
| }
|
|
|
| void test_indexUnit_nullUnit() {
|
| @@ -86,55 +78,41 @@ class LocalIndexTest extends AbstractContextTest {
|
| index.indexUnit(context, unit);
|
| }
|
|
|
| - Future test_removeContext() {
|
| + void test_removeContext() {
|
| _indexTest('main() {}');
|
| - return _getDefinedFunctions().then((locations) {
|
| - // OK, there is a location
|
| - _assertElementNames(locations, ['main']);
|
| - // remove context
|
| - index.removeContext(context);
|
| - return _getDefinedFunctions().then((locations) {
|
| - expect(locations, isEmpty);
|
| - });
|
| - });
|
| + // OK, there is an element
|
| + _assertElementNames(_getTopElements(), ['main']);
|
| + // remove context
|
| + index.removeContext(context);
|
| + expect(_getTopElements(), isEmpty);
|
| }
|
|
|
| - Future test_removeSource() {
|
| + void test_removeSource() {
|
| Source sourceA = _indexLibraryUnit('/testA.dart', 'fa() {}');
|
| _indexLibraryUnit('/testB.dart', 'fb() {}');
|
| - return _getDefinedFunctions().then((locations) {
|
| // OK, there are 2 functions
|
| - _assertElementNames(locations, ['fa', 'fb']);
|
| - // remove source
|
| - index.removeSource(context, sourceA);
|
| - return _getDefinedFunctions().then((locations) {
|
| - _assertElementNames(locations, ['fb']);
|
| - });
|
| - });
|
| + _assertElementNames(_getTopElements(), ['fa', 'fb']);
|
| + // remove source
|
| + index.removeSource(context, sourceA);
|
| + _assertElementNames(_getTopElements(), ['fb']);
|
| }
|
|
|
| - Future test_removeSources() {
|
| + void test_removeSources() {
|
| Source sourceA = _indexLibraryUnit('/testA.dart', 'fa() {}');
|
| _indexLibraryUnit('/testB.dart', 'fb() {}');
|
| - return _getDefinedFunctions().then((locations) {
|
| - // OK, there are 2 functions
|
| - _assertElementNames(locations, ['fa', 'fb']);
|
| + // OK, there are 2 functions
|
| + _assertElementNames(_getTopElements(), ['fa', 'fb']);
|
| // remove source(s)
|
| - index.removeSources(context, new SingleSourceContainer(sourceA));
|
| - return _getDefinedFunctions().then((locations) {
|
| - _assertElementNames(locations, ['fb']);
|
| - });
|
| - });
|
| + index.removeSources(context, new SingleSourceContainer(sourceA));
|
| + _assertElementNames(_getTopElements(), ['fb']);
|
| }
|
|
|
| void test_statistics() {
|
| expect(index.statistics, '[0 locations, 0 sources, 0 names]');
|
| }
|
|
|
| - Future<List<Location>> _getDefinedFunctions() {
|
| - return index.getRelationships(
|
| - UniverseElement.INSTANCE,
|
| - IndexConstants.DEFINES);
|
| + List<Element> _getTopElements() {
|
| + return index.getTopDeclarations((_) => true);
|
| }
|
|
|
| Source _indexLibraryUnit(String path, String content) {
|
|
|