| Index: pkg/analysis_server/test/analysis/notification_navigation_test.dart
|
| diff --git a/pkg/analysis_server/test/analysis/notification_navigation_test.dart b/pkg/analysis_server/test/analysis/notification_navigation_test.dart
|
| index 00ce0c9e7b8bc6d1ac096e57559bed95e88998c5..386c0ff13397ffef0d11b4b3c25c941dfdfa723e 100644
|
| --- a/pkg/analysis_server/test/analysis/notification_navigation_test.dart
|
| +++ b/pkg/analysis_server/test/analysis/notification_navigation_test.dart
|
| @@ -123,6 +123,17 @@ class AnalysisNotificationNavigationTest extends AbstractAnalysisTest {
|
| findRegion(offset, length, false);
|
| }
|
|
|
| + void assertRegionsSorted() {
|
| + int lastEnd = -1;
|
| + for (NavigationRegion region in regions) {
|
| + int offset = region.offset;
|
| + if (offset < lastEnd) {
|
| + fail('$lastEnd was expected to be > $offset in\n' + regions.join('\n'));
|
| + }
|
| + lastEnd = offset + region.length;
|
| + }
|
| + }
|
| +
|
| /**
|
| * Finds the navigation region with the given [offset] and [length].
|
| * If [length] is `-1`, then it is ignored.
|
| @@ -156,7 +167,9 @@ class AnalysisNotificationNavigationTest extends AbstractAnalysisTest {
|
|
|
| Future prepareNavigation() {
|
| addAnalysisSubscription(AnalysisService.NAVIGATION, testFile);
|
| - return waitForTasksFinished();
|
| + return waitForTasksFinished().then((_) {
|
| + assertRegionsSorted();
|
| + });
|
| }
|
|
|
| void processNotification(Notification notification) {
|
| @@ -283,6 +296,19 @@ main() {
|
| });
|
| }
|
|
|
| + test_identifier_whenStrayImportDirective() {
|
| + addTestFile('''
|
| +main() {
|
| + int aaa = 42;
|
| + print(aaa);
|
| +}
|
| +import 'dart:math';
|
| +''');
|
| + return prepareNavigation().then((_) {
|
| + assertHasRegionTarget('aaa);', 'aaa = 42');
|
| + });
|
| + }
|
| +
|
| test_instanceCreation_implicit() {
|
| addTestFile('''
|
| class A {
|
| @@ -308,7 +334,7 @@ main() {
|
| ''');
|
| return prepareNavigation().then((_) {
|
| {
|
| - findRegion(findOffset('new '), 'new '.length, true);
|
| + findRegion(findOffset('new '), 'new'.length, true);
|
| assertHasTarget('named() {}');
|
| }
|
| {
|
| @@ -333,7 +359,7 @@ main() {
|
| ''');
|
| return prepareNavigation().then((_) {
|
| {
|
| - findRegion(findOffset('new '), 'new '.length, true);
|
| + findRegion(findOffset('new '), 'new'.length, true);
|
| assertHasTarget('A() {}', 0);
|
| }
|
| {
|
|
|