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.services.completion.contributor.dart.importuri; | 5 library test.services.completion.contributor.dart.importuri; |
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/services/completion/dart_completion_manager.
dart'; | 8 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
9 import 'package:analysis_server/src/services/completion/uri_contributor.dart'; | 9 import 'package:analysis_server/src/services/completion/uri_contributor.dart'; |
10 import 'package:analyzer/file_system/memory_file_system.dart'; | 10 import 'package:analyzer/file_system/memory_file_system.dart'; |
(...skipping 10 matching lines...) Expand all Loading... |
21 defineReflectiveTests(UriContributorWindowsTest); | 21 defineReflectiveTests(UriContributorWindowsTest); |
22 } | 22 } |
23 | 23 |
24 @reflectiveTest | 24 @reflectiveTest |
25 class UriContributorTest extends AbstractCompletionTest { | 25 class UriContributorTest extends AbstractCompletionTest { |
26 @override | 26 @override |
27 void setUpContributor() { | 27 void setUpContributor() { |
28 contributor = new UriContributor(); | 28 contributor = new UriContributor(); |
29 } | 29 } |
30 | 30 |
| 31 test_after_import() { |
| 32 addTestSource('import "p"^'); |
| 33 computeFast(); |
| 34 expect(request.replacementOffset, completionOffset); |
| 35 expect(request.replacementLength, 0); |
| 36 assertNoSuggestions(); |
| 37 } |
| 38 |
| 39 test_after_import_raw() { |
| 40 addTestSource('import r"p"^'); |
| 41 computeFast(); |
| 42 expect(request.replacementOffset, completionOffset); |
| 43 expect(request.replacementLength, 0); |
| 44 assertNoSuggestions(); |
| 45 } |
| 46 |
| 47 test_before_import() { |
| 48 addTestSource('import ^"p"'); |
| 49 computeFast(); |
| 50 expect(request.replacementOffset, completionOffset); |
| 51 expect(request.replacementLength, 0); |
| 52 assertNoSuggestions(); |
| 53 } |
| 54 |
| 55 test_before_import_raw() { |
| 56 addTestSource('import ^r"p"'); |
| 57 computeFast(); |
| 58 expect(request.replacementOffset, completionOffset); |
| 59 expect(request.replacementLength, 0); |
| 60 assertNoSuggestions(); |
| 61 } |
| 62 |
| 63 test_before_import_raw2() { |
| 64 addTestSource('import r^"p"'); |
| 65 computeFast(); |
| 66 expect(request.replacementOffset, completionOffset); |
| 67 expect(request.replacementLength, 0); |
| 68 assertNoSuggestions(); |
| 69 } |
| 70 |
31 test_export_package2() { | 71 test_export_package2() { |
32 addPackageSource('foo', 'foo.dart', 'library foo;'); | 72 addPackageSource('foo', 'foo.dart', 'library foo;'); |
33 addPackageSource('foo', 'baz/too.dart', 'library too;'); | 73 addPackageSource('foo', 'baz/too.dart', 'library too;'); |
34 addPackageSource('bar', 'bar.dart', 'library bar;'); | 74 addPackageSource('bar', 'bar.dart', 'library bar;'); |
35 addTestSource('export "package:foo/baz/^" import'); | 75 addTestSource('export "package:foo/baz/^" import'); |
36 computeFast(); | 76 computeFast(); |
37 assertSuggest('package:foo/baz/too.dart', | 77 assertSuggest('package:foo/baz/too.dart', |
38 csKind: CompletionSuggestionKind.IMPORT); | 78 csKind: CompletionSuggestionKind.IMPORT); |
39 } | 79 } |
40 | 80 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 test_import_package2() { | 229 test_import_package2() { |
190 addPackageSource('foo', 'foo.dart', 'library foo;'); | 230 addPackageSource('foo', 'foo.dart', 'library foo;'); |
191 addPackageSource('foo', 'baz/too.dart', 'library too;'); | 231 addPackageSource('foo', 'baz/too.dart', 'library too;'); |
192 addPackageSource('bar', 'bar.dart', 'library bar;'); | 232 addPackageSource('bar', 'bar.dart', 'library bar;'); |
193 addTestSource('import "package:foo/baz/^" import'); | 233 addTestSource('import "package:foo/baz/^" import'); |
194 computeFast(); | 234 computeFast(); |
195 assertSuggest('package:foo/baz/too.dart', | 235 assertSuggest('package:foo/baz/too.dart', |
196 csKind: CompletionSuggestionKind.IMPORT); | 236 csKind: CompletionSuggestionKind.IMPORT); |
197 } | 237 } |
198 | 238 |
| 239 test_import_package2_raw() { |
| 240 addPackageSource('foo', 'foo.dart', 'library foo;'); |
| 241 addPackageSource('foo', 'baz/too.dart', 'library too;'); |
| 242 addPackageSource('bar', 'bar.dart', 'library bar;'); |
| 243 addTestSource('import r"package:foo/baz/^" import'); |
| 244 computeFast(); |
| 245 assertSuggest('package:foo/baz/too.dart', |
| 246 csKind: CompletionSuggestionKind.IMPORT); |
| 247 } |
| 248 |
199 test_import_package_missing_lib() { | 249 test_import_package_missing_lib() { |
200 var pkgSrc = addPackageSource('bar', 'bar.dart', 'library bar;'); | 250 var pkgSrc = addPackageSource('bar', 'bar.dart', 'library bar;'); |
201 provider.deleteFolder(dirname(pkgSrc.fullName)); | 251 provider.deleteFolder(dirname(pkgSrc.fullName)); |
202 addTestSource('import "p^" class'); | 252 addTestSource('import "p^" class'); |
203 computeFast(); | 253 computeFast(); |
204 expect(request.replacementOffset, completionOffset - 1); | 254 expect(request.replacementOffset, completionOffset - 1); |
205 expect(request.replacementLength, 1); | 255 expect(request.replacementLength, 1); |
206 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); | 256 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); |
207 assertSuggest('package:bar/', csKind: CompletionSuggestionKind.IMPORT); | 257 assertSuggest('package:bar/', csKind: CompletionSuggestionKind.IMPORT); |
208 assertNotSuggested('package:bar/bar.dart'); | 258 assertNotSuggested('package:bar/bar.dart'); |
209 } | 259 } |
210 | 260 |
| 261 test_import_package_raw() { |
| 262 addPackageSource('foo', 'foo.dart', 'library foo;'); |
| 263 addPackageSource('foo', 'baz/too.dart', 'library too;'); |
| 264 addPackageSource('bar', 'bar.dart', 'library bar;'); |
| 265 addTestSource('import r"p^" import'); |
| 266 computeFast(); |
| 267 expect(request.replacementOffset, completionOffset - 1); |
| 268 expect(request.replacementLength, 1); |
| 269 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); |
| 270 assertSuggest('package:foo/', csKind: CompletionSuggestionKind.IMPORT); |
| 271 assertSuggest('package:foo/foo.dart', |
| 272 csKind: CompletionSuggestionKind.IMPORT); |
| 273 assertSuggest('package:foo/baz/', csKind: CompletionSuggestionKind.IMPORT); |
| 274 assertNotSuggested('package:foo/baz/too.dart'); |
| 275 assertSuggest('package:bar/', csKind: CompletionSuggestionKind.IMPORT); |
| 276 assertSuggest('package:bar/bar.dart', |
| 277 csKind: CompletionSuggestionKind.IMPORT); |
| 278 } |
| 279 |
| 280 test_import_raw() { |
| 281 addTestSource('import r"^" import'); |
| 282 computeFast(); |
| 283 expect(request.replacementOffset, completionOffset); |
| 284 expect(request.replacementLength, 0); |
| 285 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT); |
| 286 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); |
| 287 } |
| 288 |
211 test_outside_import() { | 289 test_outside_import() { |
212 addTestSource('import ^"d" import'); | 290 addTestSource('import ^"d" import'); |
213 computeFast(); | 291 computeFast(); |
214 computeFull((_) { | 292 computeFull((_) { |
215 assertNoSuggestions(); | 293 assertNoSuggestions(); |
216 }); | 294 }); |
217 } | 295 } |
218 | 296 |
219 test_outside_import2() { | 297 test_outside_import2() { |
220 addTestSource('import "d"^ import'); | 298 addTestSource('import "d"^ import'); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 assertNotSuggested('foo/'); | 534 assertNotSuggested('foo/'); |
457 assertNotSuggested('foo/bar.dart'); | 535 assertNotSuggested('foo/bar.dart'); |
458 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); | 536 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); |
459 } | 537 } |
460 } | 538 } |
461 | 539 |
462 class _TestWinResourceProvider extends MemoryResourceProvider { | 540 class _TestWinResourceProvider extends MemoryResourceProvider { |
463 @override | 541 @override |
464 Context get pathContext => windows; | 542 Context get pathContext => windows; |
465 } | 543 } |
OLD | NEW |