| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.integration.analysis.packageRoot; | 5 library test.integration.analysis.packageRoot; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
| 8 import 'package:path/path.dart'; | 8 import 'package:path/path.dart'; |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 f() {} | 37 f() {} |
| 38 """; | 38 """; |
| 39 writeFile(mainPath, mainText); | 39 writeFile(mainPath, mainText); |
| 40 String normalizedFooBarPath = writeFile(fooBarPath, fooBarText); | 40 String normalizedFooBarPath = writeFile(fooBarPath, fooBarText); |
| 41 sendServerSetSubscriptions([ServerService.STATUS]); | 41 sendServerSetSubscriptions([ServerService.STATUS]); |
| 42 sendAnalysisSetSubscriptions({ | 42 sendAnalysisSetSubscriptions({ |
| 43 AnalysisService.NAVIGATION: [mainPath] | 43 AnalysisService.NAVIGATION: [mainPath] |
| 44 }); | 44 }); |
| 45 List<NavigationRegion> navigationRegions; | 45 List<NavigationRegion> navigationRegions; |
| 46 List<NavigationTarget> navigationTargets; |
| 47 List<String> navigationTargetFiles; |
| 46 onAnalysisNavigation.listen((AnalysisNavigationParams params) { | 48 onAnalysisNavigation.listen((AnalysisNavigationParams params) { |
| 47 expect(params.file, equals(mainPath)); | 49 expect(params.file, equals(mainPath)); |
| 48 navigationRegions = params.regions; | 50 navigationRegions = params.regions; |
| 51 navigationTargets = params.targets; |
| 52 navigationTargetFiles = params.targetFiles; |
| 49 }); | 53 }); |
| 50 sendAnalysisSetAnalysisRoots([projPath], [], packageRoots: { | 54 sendAnalysisSetAnalysisRoots([projPath], [], packageRoots: { |
| 51 projPath: packagesPath | 55 projPath: packagesPath |
| 52 }); | 56 }); |
| 53 return analysisFinished.then((_) { | 57 return analysisFinished.then((_) { |
| 54 // Verify that fooBarPath was properly resolved by checking that f() | 58 // Verify that fooBarPath was properly resolved by checking that f() |
| 55 // refers to it. | 59 // refers to it. |
| 56 bool found = false; | 60 bool found = false; |
| 57 for (NavigationRegion region in navigationRegions) { | 61 for (NavigationRegion region in navigationRegions) { |
| 58 String navigationSource = | 62 String navigationSource = |
| 59 mainText.substring(region.offset, region.offset + region.length); | 63 mainText.substring(region.offset, region.offset + region.length); |
| 60 if (navigationSource == 'f') { | 64 if (navigationSource == 'f') { |
| 61 found = true; | 65 found = true; |
| 62 expect(region.targets, hasLength(1)); | 66 expect(region.targetIndexes, hasLength(1)); |
| 63 Location location = region.targets[0].location; | 67 int navigationTargetIndex = region.targetIndexes[0]; |
| 64 expect(location.file, equals(normalizedFooBarPath)); | 68 NavigationTarget navigationTarget = navigationTargets[navigationTarget
Index]; |
| 69 String navigationFile = navigationTargetFiles[navigationTarget.fileInd
ex]; |
| 70 expect(navigationFile, equals(normalizedFooBarPath)); |
| 65 } | 71 } |
| 66 } | 72 } |
| 67 expect(found, isTrue); | 73 expect(found, isTrue); |
| 68 }); | 74 }); |
| 69 } | 75 } |
| 70 } | 76 } |
| OLD | NEW |