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.analysis.get_navigation; | 5 library test.analysis.get_navigation; |
6 | 6 |
7 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 7 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
8 import 'package:analysis_server/src/domain_analysis.dart'; | 8 import 'package:analysis_server/src/domain_analysis.dart'; |
9 import 'package:analyzer/file_system/file_system.dart'; | 9 import 'package:analyzer/file_system/file_system.dart'; |
10 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 addFile( | 51 addFile( |
52 file, | 52 file, |
53 ''' | 53 ''' |
54 main() { | 54 main() { |
55 print(42); | 55 print(42); |
56 } | 56 } |
57 '''); | 57 '''); |
58 return _checkInvalid(file, -1, -1); | 58 return _checkInvalid(file, -1, -1); |
59 } | 59 } |
60 | 60 |
| 61 test_issue24599_importDirective() async { |
| 62 addTestFile(''' |
| 63 import 'dart:math'; |
| 64 |
| 65 main() { |
| 66 }'''); |
| 67 await waitForTasksFinished(); |
| 68 await _getNavigation(testFile, 0, 17); |
| 69 expect(regions, hasLength(1)); |
| 70 assertHasRegionString("'dart:math'"); |
| 71 expect(testTargets, hasLength(1)); |
| 72 expect(testTargets[0].kind, ElementKind.LIBRARY); |
| 73 } |
| 74 |
| 75 test_issue24599_importKeyword() async { |
| 76 addTestFile(''' |
| 77 import 'dart:math'; |
| 78 |
| 79 main() { |
| 80 }'''); |
| 81 await waitForTasksFinished(); |
| 82 await _getNavigation(testFile, 0, 1); |
| 83 expect(regions, hasLength(1)); |
| 84 assertHasRegionString("'dart:math'"); |
| 85 expect(testTargets, hasLength(1)); |
| 86 expect(testTargets[0].kind, ElementKind.LIBRARY); |
| 87 } |
| 88 |
| 89 test_issue24599_importUri() async { |
| 90 addTestFile(''' |
| 91 import 'dart:math'; |
| 92 |
| 93 main() { |
| 94 }'''); |
| 95 await waitForTasksFinished(); |
| 96 await _getNavigation(testFile, 7, 11); |
| 97 expect(regions, hasLength(1)); |
| 98 assertHasRegionString("'dart:math'"); |
| 99 expect(testTargets, hasLength(1)); |
| 100 expect(testTargets[0].kind, ElementKind.LIBRARY); |
| 101 } |
| 102 |
61 test_multipleRegions() async { | 103 test_multipleRegions() async { |
62 addTestFile(''' | 104 addTestFile(''' |
63 main() { | 105 main() { |
64 var aaa = 1; | 106 var aaa = 1; |
65 var bbb = 2; | 107 var bbb = 2; |
66 var ccc = 3; | 108 var ccc = 3; |
67 var ddd = 4; | 109 var ddd = 4; |
68 print(aaa + bbb + ccc + ddd); | 110 print(aaa + bbb + ccc + ddd); |
69 } | 111 } |
70 '''); | 112 '''); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 _getNavigation(String file, int offset, int length) async { | 193 _getNavigation(String file, int offset, int length) async { |
152 Request request = _createGetNavigationRequest(file, offset, length); | 194 Request request = _createGetNavigationRequest(file, offset, length); |
153 Response response = await serverChannel.sendRequest(request); | 195 Response response = await serverChannel.sendRequest(request); |
154 AnalysisGetNavigationResult result = | 196 AnalysisGetNavigationResult result = |
155 new AnalysisGetNavigationResult.fromResponse(response); | 197 new AnalysisGetNavigationResult.fromResponse(response); |
156 targetFiles = result.files; | 198 targetFiles = result.files; |
157 targets = result.targets; | 199 targets = result.targets; |
158 regions = result.regions; | 200 regions = result.regions; |
159 } | 201 } |
160 } | 202 } |
OLD | NEW |