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.context.directory.manager; | 5 library test.context.directory.manager; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analysis_server/src/context_manager.dart'; | 9 import 'package:analysis_server/src/context_manager.dart'; |
10 import 'package:analysis_server/src/source/optimizing_pub_package_map_provider.d
art'; | 10 import 'package:analysis_server/src/source/optimizing_pub_package_map_provider.d
art'; |
11 import 'package:analysis_server/uri/resolver_provider.dart'; | 11 import 'package:analysis_server/uri/resolver_provider.dart'; |
12 import 'package:analyzer/file_system/file_system.dart'; | 12 import 'package:analyzer/file_system/file_system.dart'; |
13 import 'package:analyzer/file_system/memory_file_system.dart'; | 13 import 'package:analyzer/file_system/memory_file_system.dart'; |
14 import 'package:analyzer/instrumentation/instrumentation.dart'; | 14 import 'package:analyzer/instrumentation/instrumentation.dart'; |
15 import 'package:analyzer/source/package_map_resolver.dart'; | 15 import 'package:analyzer/source/package_map_resolver.dart'; |
16 import 'package:analyzer/source/path_filter.dart'; | 16 import 'package:analyzer/source/path_filter.dart'; |
17 import 'package:analyzer/src/generated/engine.dart'; | 17 import 'package:analyzer/src/generated/engine.dart'; |
18 import 'package:analyzer/src/generated/source.dart'; | 18 import 'package:analyzer/src/generated/source.dart'; |
19 import 'package:analyzer/src/generated/source_io.dart'; | 19 import 'package:analyzer/src/generated/source_io.dart'; |
| 20 import 'package:package_config/packages.dart'; |
20 import 'package:path/path.dart'; | 21 import 'package:path/path.dart'; |
21 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 22 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
22 import 'package:unittest/unittest.dart'; | 23 import 'package:unittest/unittest.dart'; |
23 | 24 |
24 import 'mocks.dart'; | 25 import 'mocks.dart'; |
25 | 26 |
26 main() { | 27 main() { |
27 groupSep = ' | '; | 28 groupSep = ' | '; |
28 defineReflectiveTests(AbstractContextManagerTest); | 29 defineReflectiveTests(AbstractContextManagerTest); |
29 } | 30 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 UriResolver providePackageResolver(Folder folder) { | 81 UriResolver providePackageResolver(Folder folder) { |
81 return packageResolver; | 82 return packageResolver; |
82 } | 83 } |
83 | 84 |
84 void setUp() { | 85 void setUp() { |
85 resourceProvider = new MemoryResourceProvider(); | 86 resourceProvider = new MemoryResourceProvider(); |
86 packageMapProvider = new MockPackageMapProvider(); | 87 packageMapProvider = new MockPackageMapProvider(); |
87 manager = new TestContextManager( | 88 manager = new TestContextManager( |
88 resourceProvider, providePackageResolver, packageMapProvider); | 89 resourceProvider, providePackageResolver, packageMapProvider); |
89 resourceProvider.newFolder(projPath); | 90 resourceProvider.newFolder(projPath); |
| 91 AbstractContextManager.ENABLE_PACKAGESPEC_SUPPORT = true; |
| 92 } |
| 93 |
| 94 void tearDown() { |
| 95 AbstractContextManager.ENABLE_PACKAGESPEC_SUPPORT = false; |
90 } | 96 } |
91 | 97 |
92 test_ignoreFilesInPackagesFolder() { | 98 test_ignoreFilesInPackagesFolder() { |
93 // create a context with a pubspec.yaml file | 99 // create a context with a pubspec.yaml file |
94 String pubspecPath = posix.join(projPath, 'pubspec.yaml'); | 100 String pubspecPath = posix.join(projPath, 'pubspec.yaml'); |
95 resourceProvider.newFile(pubspecPath, 'pubspec'); | 101 resourceProvider.newFile(pubspecPath, 'pubspec'); |
96 // create a file in the "packages" folder | 102 // create a file in the "packages" folder |
97 String filePath1 = posix.join(projPath, 'packages', 'file1.dart'); | 103 String filePath1 = posix.join(projPath, 'packages', 'file1.dart'); |
98 resourceProvider.newFile(filePath1, 'contents'); | 104 resourceProvider.newFile(filePath1, 'contents'); |
99 // "packages" files are ignored initially | 105 // "packages" files are ignored initially |
(...skipping 23 matching lines...) Expand all Loading... |
123 void test_isInAnalysisRoot_inRoot() { | 129 void test_isInAnalysisRoot_inRoot() { |
124 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 130 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
125 expect(manager.isInAnalysisRoot('$projPath/test.dart'), isTrue); | 131 expect(manager.isInAnalysisRoot('$projPath/test.dart'), isTrue); |
126 } | 132 } |
127 | 133 |
128 void test_isInAnalysisRoot_notInRoot() { | 134 void test_isInAnalysisRoot_notInRoot() { |
129 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 135 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
130 expect(manager.isInAnalysisRoot('/test.dart'), isFalse); | 136 expect(manager.isInAnalysisRoot('/test.dart'), isFalse); |
131 } | 137 } |
132 | 138 |
| 139 test_refresh_folder_with_packagespec() { |
| 140 // create a context with a .packages file |
| 141 String packagespecFile = posix.join(projPath, '.packages'); |
| 142 resourceProvider.newFile(packagespecFile, ''); |
| 143 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| 144 return pumpEventQueue().then((_) { |
| 145 expect(manager.currentContextPaths.toList(), [projPath]); |
| 146 manager.now++; |
| 147 manager.refresh(null); |
| 148 return pumpEventQueue().then((_) { |
| 149 expect(manager.currentContextPaths.toList(), [projPath]); |
| 150 expect(manager.currentContextTimestamps[projPath], manager.now); |
| 151 }); |
| 152 }); |
| 153 } |
| 154 |
| 155 test_refresh_folder_with_packagespec_subfolders() { |
| 156 // Create a folder with no .packages file, containing two subfolders with |
| 157 // .packages files. |
| 158 String subdir1Path = posix.join(projPath, 'subdir1'); |
| 159 String subdir2Path = posix.join(projPath, 'subdir2'); |
| 160 String packagespec1Path = posix.join(subdir1Path, '.packages'); |
| 161 String packagespec2Path = posix.join(subdir2Path, '.packages'); |
| 162 resourceProvider.newFile(packagespec1Path, ''); |
| 163 resourceProvider.newFile(packagespec2Path, ''); |
| 164 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| 165 return pumpEventQueue().then((_) { |
| 166 expect(manager.currentContextPaths.toSet(), |
| 167 [subdir1Path, subdir2Path, projPath].toSet()); |
| 168 manager.now++; |
| 169 manager.refresh(null); |
| 170 return pumpEventQueue().then((_) { |
| 171 expect(manager.currentContextPaths.toSet(), |
| 172 [subdir1Path, subdir2Path, projPath].toSet()); |
| 173 expect(manager.currentContextTimestamps[projPath], manager.now); |
| 174 expect(manager.currentContextTimestamps[subdir1Path], manager.now); |
| 175 expect(manager.currentContextTimestamps[subdir2Path], manager.now); |
| 176 }); |
| 177 }); |
| 178 } |
| 179 |
133 test_refresh_folder_with_pubspec() { | 180 test_refresh_folder_with_pubspec() { |
134 // create a context with a pubspec.yaml file | 181 // create a context with a pubspec.yaml file |
135 String pubspecPath = posix.join(projPath, 'pubspec.yaml'); | 182 String pubspecPath = posix.join(projPath, 'pubspec.yaml'); |
136 resourceProvider.newFile(pubspecPath, 'pubspec'); | 183 resourceProvider.newFile(pubspecPath, 'pubspec'); |
137 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 184 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
138 return pumpEventQueue().then((_) { | 185 return pumpEventQueue().then((_) { |
139 expect(manager.currentContextPaths.toList(), [projPath]); | 186 expect(manager.currentContextPaths.toList(), [projPath]); |
140 manager.now++; | 187 manager.now++; |
141 manager.refresh(null); | 188 manager.refresh(null); |
142 return pumpEventQueue().then((_) { | 189 return pumpEventQueue().then((_) { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 300 |
254 void test_setRoots_addFolderWithDummyLink() { | 301 void test_setRoots_addFolderWithDummyLink() { |
255 String filePath = posix.join(projPath, 'foo.dart'); | 302 String filePath = posix.join(projPath, 'foo.dart'); |
256 resourceProvider.newDummyLink(filePath); | 303 resourceProvider.newDummyLink(filePath); |
257 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 304 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
258 // verify | 305 // verify |
259 var filePaths = manager.currentContextFilePaths[projPath]; | 306 var filePaths = manager.currentContextFilePaths[projPath]; |
260 expect(filePaths, isEmpty); | 307 expect(filePaths, isEmpty); |
261 } | 308 } |
262 | 309 |
| 310 void test_setRoots_addFolderWithNestedPackageSpec() { |
| 311 String examplePath = newFolder([projPath, EXAMPLE_NAME]); |
| 312 String libPath = newFolder([projPath, LIB_NAME]); |
| 313 |
| 314 newFile([projPath, AbstractContextManager.PACKAGE_SPEC_NAME]); |
| 315 newFile([libPath, 'main.dart']); |
| 316 newFile([examplePath, AbstractContextManager.PACKAGE_SPEC_NAME]); |
| 317 newFile([examplePath, 'example.dart']); |
| 318 |
| 319 packageMapProvider.packageMap['proj'] = |
| 320 [resourceProvider.getResource(libPath)]; |
| 321 |
| 322 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| 323 |
| 324 expect(manager.currentContextPaths, hasLength(2)); |
| 325 |
| 326 expect(manager.currentContextPaths, contains(projPath)); |
| 327 Set<Source> projSources = manager.currentContextSources[projPath]; |
| 328 expect(projSources, hasLength(1)); |
| 329 expect(projSources.first.uri.toString(), 'file:///my/proj/lib/main.dart'); |
| 330 |
| 331 expect(manager.currentContextPaths, contains(examplePath)); |
| 332 Set<Source> exampleSources = manager.currentContextSources[examplePath]; |
| 333 expect(exampleSources, hasLength(1)); |
| 334 expect(exampleSources.first.uri.toString(), |
| 335 'file:///my/proj/example/example.dart'); |
| 336 } |
| 337 |
263 void test_setRoots_addFolderWithNestedPubspec() { | 338 void test_setRoots_addFolderWithNestedPubspec() { |
264 String examplePath = newFolder([projPath, EXAMPLE_NAME]); | 339 String examplePath = newFolder([projPath, EXAMPLE_NAME]); |
265 String libPath = newFolder([projPath, LIB_NAME]); | 340 String libPath = newFolder([projPath, LIB_NAME]); |
266 | 341 |
267 newFile([projPath, AbstractContextManager.PUBSPEC_NAME]); | 342 newFile([projPath, AbstractContextManager.PUBSPEC_NAME]); |
268 newFile([libPath, 'main.dart']); | 343 newFile([libPath, 'main.dart']); |
269 newFile([examplePath, AbstractContextManager.PUBSPEC_NAME]); | 344 newFile([examplePath, AbstractContextManager.PUBSPEC_NAME]); |
270 newFile([examplePath, 'example.dart']); | 345 newFile([examplePath, 'example.dart']); |
271 | 346 |
272 packageMapProvider.packageMap['proj'] = | 347 packageMapProvider.packageMap['proj'] = |
(...skipping 17 matching lines...) Expand all Loading... |
290 | 365 |
291 void test_setRoots_addFolderWithoutPubspec() { | 366 void test_setRoots_addFolderWithoutPubspec() { |
292 packageMapProvider.packageMap = null; | 367 packageMapProvider.packageMap = null; |
293 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 368 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
294 // verify | 369 // verify |
295 expect(manager.currentContextPaths, hasLength(1)); | 370 expect(manager.currentContextPaths, hasLength(1)); |
296 expect(manager.currentContextPaths, contains(projPath)); | 371 expect(manager.currentContextPaths, contains(projPath)); |
297 expect(manager.currentContextFilePaths[projPath], hasLength(0)); | 372 expect(manager.currentContextFilePaths[projPath], hasLength(0)); |
298 } | 373 } |
299 | 374 |
| 375 void test_setRoots_addFolderWithPackagespec() { |
| 376 String packagespecPath = posix.join(projPath, '.packages'); |
| 377 resourceProvider.newFile(packagespecPath, |
| 378 'unittest:file:///home/somebody/.pub/cache/unittest-0.9.9/lib/'); |
| 379 String libPath = newFolder([projPath, LIB_NAME]); |
| 380 File mainFile = |
| 381 resourceProvider.newFile(posix.join(libPath, 'main.dart'), ''); |
| 382 Source source = mainFile.createSource(); |
| 383 |
| 384 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| 385 |
| 386 // verify |
| 387 expect(manager.currentContextPaths, hasLength(1)); |
| 388 expect(manager.currentContextPaths, contains(projPath)); |
| 389 expect(manager.currentContextFilePaths[projPath], hasLength(1)); |
| 390 |
| 391 // smoketest resolution |
| 392 SourceFactory sourceFactory = manager.currentContext.sourceFactory; |
| 393 Source resolvedSource = |
| 394 sourceFactory.resolveUri(source, 'package:unittest/unittest.dart'); |
| 395 expect(resolvedSource, isNotNull); |
| 396 expect(resolvedSource.fullName, |
| 397 equals('/home/somebody/.pub/cache/unittest-0.9.9/lib/unittest.dart')); |
| 398 } |
| 399 |
300 void test_setRoots_addFolderWithPubspec() { | 400 void test_setRoots_addFolderWithPubspec() { |
301 String pubspecPath = posix.join(projPath, 'pubspec.yaml'); | 401 String pubspecPath = posix.join(projPath, 'pubspec.yaml'); |
302 resourceProvider.newFile(pubspecPath, 'pubspec'); | 402 resourceProvider.newFile(pubspecPath, 'pubspec'); |
303 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 403 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
304 // verify | 404 // verify |
305 expect(manager.currentContextPaths, hasLength(1)); | 405 expect(manager.currentContextPaths, hasLength(1)); |
306 expect(manager.currentContextPaths, contains(projPath)); | 406 expect(manager.currentContextPaths, contains(projPath)); |
307 expect(manager.currentContextFilePaths[projPath], hasLength(0)); | 407 expect(manager.currentContextFilePaths[projPath], hasLength(0)); |
308 } | 408 } |
309 | 409 |
| 410 void test_setRoots_addFolderWithPubspec_andPackagespec() { |
| 411 String pubspecPath = posix.join(projPath, 'pubspec.yaml'); |
| 412 String packagespecPath = posix.join(projPath, '.packages'); |
| 413 resourceProvider.newFile(pubspecPath, 'pubspec'); |
| 414 resourceProvider.newFile(packagespecPath, ''); |
| 415 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| 416 // verify |
| 417 manager.assertContextPaths([projPath]); |
| 418 } |
| 419 |
310 void test_setRoots_addFolderWithPubspecAndLib() { | 420 void test_setRoots_addFolderWithPubspecAndLib() { |
311 String binPath = newFolder([projPath, BIN_NAME]); | 421 String binPath = newFolder([projPath, BIN_NAME]); |
312 String libPath = newFolder([projPath, LIB_NAME]); | 422 String libPath = newFolder([projPath, LIB_NAME]); |
313 String srcPath = newFolder([libPath, SRC_NAME]); | 423 String srcPath = newFolder([libPath, SRC_NAME]); |
314 String testPath = newFolder([projPath, TEST_NAME]); | 424 String testPath = newFolder([projPath, TEST_NAME]); |
315 | 425 |
316 newFile([projPath, AbstractContextManager.PUBSPEC_NAME]); | 426 newFile([projPath, AbstractContextManager.PUBSPEC_NAME]); |
317 String appPath = newFile([binPath, 'app.dart']); | 427 String appPath = newFile([binPath, 'app.dart']); |
318 newFile([libPath, 'main.dart']); | 428 newFile([libPath, 'main.dart']); |
319 newFile([srcPath, 'internal.dart']); | 429 newFile([srcPath, 'internal.dart']); |
320 String testFilePath = newFile([testPath, 'main_test.dart']); | 430 String testFilePath = newFile([testPath, 'main_test.dart']); |
321 | 431 |
322 packageMapProvider.packageMap['proj'] = | 432 packageMapProvider.packageMap['proj'] = |
323 [resourceProvider.getResource(libPath)]; | 433 [resourceProvider.getResource(libPath)]; |
324 | 434 |
325 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 435 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
326 Set<Source> sources = manager.currentContextSources[projPath]; | 436 Set<Source> sources = manager.currentContextSources[projPath]; |
327 | 437 |
328 expect(manager.currentContextPaths, hasLength(1)); | 438 expect(manager.currentContextPaths, hasLength(1)); |
329 expect(manager.currentContextPaths, contains(projPath)); | 439 expect(manager.currentContextPaths, contains(projPath)); |
330 expect(sources, hasLength(4)); | 440 expect(sources, hasLength(4)); |
331 List<String> uris = | 441 List<String> uris = |
332 sources.map((Source source) => source.uri.toString()).toList(); | 442 sources.map((Source source) => source.uri.toString()).toList(); |
333 expect(uris, contains('file://$appPath')); | 443 expect(uris, contains('file://$appPath')); |
334 expect(uris, contains('package:proj/main.dart')); | 444 expect(uris, contains('package:proj/main.dart')); |
335 expect(uris, contains('package:proj/src/internal.dart')); | 445 expect(uris, contains('package:proj/src/internal.dart')); |
336 expect(uris, contains('file://$testFilePath')); | 446 expect(uris, contains('file://$testFilePath')); |
337 } | 447 } |
338 | 448 |
| 449 void test_setRoots_addFolderWithPubspecAndPackagespecFolders() { |
| 450 // prepare paths |
| 451 String root = '/root'; |
| 452 String rootFile = '$root/root.dart'; |
| 453 String subProjectA = '$root/sub/aaa'; |
| 454 String subProjectB = '$root/sub/sub2/bbb'; |
| 455 String subProjectA_file = '$subProjectA/bin/a.dart'; |
| 456 String subProjectB_file = '$subProjectB/bin/b.dart'; |
| 457 // create files |
| 458 resourceProvider.newFile('$subProjectA/pubspec.yaml', 'pubspec'); |
| 459 resourceProvider.newFile('$subProjectB/pubspec.yaml', 'pubspec'); |
| 460 resourceProvider.newFile('$subProjectA/.packages', ''); |
| 461 resourceProvider.newFile('$subProjectB/.packages', ''); |
| 462 |
| 463 resourceProvider.newFile(rootFile, 'library root;'); |
| 464 resourceProvider.newFile(subProjectA_file, 'library a;'); |
| 465 resourceProvider.newFile(subProjectB_file, 'library b;'); |
| 466 |
| 467 // set roots |
| 468 manager.setRoots(<String>[root], <String>[], <String, String>{}); |
| 469 manager.assertContextPaths([root, subProjectA, subProjectB]); |
| 470 // verify files |
| 471 manager.assertContextFiles(root, [rootFile]); |
| 472 manager.assertContextFiles(subProjectA, [subProjectA_file]); |
| 473 manager.assertContextFiles(subProjectB, [subProjectB_file]); |
| 474 } |
| 475 |
339 void test_setRoots_addFolderWithPubspecFolders() { | 476 void test_setRoots_addFolderWithPubspecFolders() { |
340 // prepare paths | 477 // prepare paths |
341 String root = '/root'; | 478 String root = '/root'; |
342 String rootFile = '$root/root.dart'; | 479 String rootFile = '$root/root.dart'; |
343 String subProjectA = '$root/sub/aaa'; | 480 String subProjectA = '$root/sub/aaa'; |
344 String subProjectB = '$root/sub/sub2/bbb'; | 481 String subProjectB = '$root/sub/sub2/bbb'; |
345 String subProjectA_file = '$subProjectA/bin/a.dart'; | 482 String subProjectA_file = '$subProjectA/bin/a.dart'; |
346 String subProjectB_file = '$subProjectB/bin/b.dart'; | 483 String subProjectB_file = '$subProjectB/bin/b.dart'; |
347 // create files | 484 // create files |
348 resourceProvider.newFile('$subProjectA/pubspec.yaml', 'pubspec'); | 485 resourceProvider.newFile('$subProjectA/pubspec.yaml', 'pubspec'); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 packageMapProvider.packageMap = null; | 698 packageMapProvider.packageMap = null; |
562 // add one root - there is a context | 699 // add one root - there is a context |
563 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 700 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
564 expect(manager.currentContextPaths, hasLength(1)); | 701 expect(manager.currentContextPaths, hasLength(1)); |
565 // set empty roots - no contexts | 702 // set empty roots - no contexts |
566 manager.setRoots(<String>[], <String>[], <String, String>{}); | 703 manager.setRoots(<String>[], <String>[], <String, String>{}); |
567 expect(manager.currentContextPaths, hasLength(0)); | 704 expect(manager.currentContextPaths, hasLength(0)); |
568 expect(manager.currentContextFilePaths, hasLength(0)); | 705 expect(manager.currentContextFilePaths, hasLength(0)); |
569 } | 706 } |
570 | 707 |
| 708 void test_setRoots_removeFolderWithPackagespec() { |
| 709 // create a pubspec |
| 710 String pubspecPath = posix.join(projPath, '.packages'); |
| 711 resourceProvider.newFile(pubspecPath, ''); |
| 712 // add one root - there is a context |
| 713 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| 714 expect(manager.currentContextPaths, hasLength(1)); |
| 715 // set empty roots - no contexts |
| 716 manager.setRoots(<String>[], <String>[], <String, String>{}); |
| 717 expect(manager.currentContextPaths, hasLength(0)); |
| 718 expect(manager.currentContextFilePaths, hasLength(0)); |
| 719 } |
| 720 |
| 721 void test_setRoots_removeFolderWithPackagespecFolder() { |
| 722 // prepare paths |
| 723 String projectA = '/projectA'; |
| 724 String projectB = '/projectB'; |
| 725 String subProjectA = '$projectA/sub'; |
| 726 String subProjectB = '$projectB/sub'; |
| 727 String projectA_file = '$projectA/a.dart'; |
| 728 String projectB_file = '$projectB/a.dart'; |
| 729 String subProjectA_pubspec = '$subProjectA/.packages'; |
| 730 String subProjectB_pubspec = '$subProjectB/.packages'; |
| 731 String subProjectA_file = '$subProjectA/bin/sub_a.dart'; |
| 732 String subProjectB_file = '$subProjectB/bin/sub_b.dart'; |
| 733 // create files |
| 734 resourceProvider.newFile(projectA_file, '// a'); |
| 735 resourceProvider.newFile(projectB_file, '// b'); |
| 736 resourceProvider.newFile(subProjectA_pubspec, ''); |
| 737 resourceProvider.newFile(subProjectB_pubspec, ''); |
| 738 resourceProvider.newFile(subProjectA_file, '// sub-a'); |
| 739 resourceProvider.newFile(subProjectB_file, '// sub-b'); |
| 740 // set roots |
| 741 manager.setRoots( |
| 742 <String>[projectA, projectB], <String>[], <String, String>{}); |
| 743 manager.assertContextPaths([projectA, subProjectA, projectB, subProjectB]); |
| 744 manager.assertContextFiles(projectA, [projectA_file]); |
| 745 manager.assertContextFiles(projectB, [projectB_file]); |
| 746 manager.assertContextFiles(subProjectA, [subProjectA_file]); |
| 747 manager.assertContextFiles(subProjectB, [subProjectB_file]); |
| 748 // remove "projectB" |
| 749 manager.setRoots(<String>[projectA], <String>[], <String, String>{}); |
| 750 manager.assertContextPaths([projectA, subProjectA]); |
| 751 manager.assertContextFiles(projectA, [projectA_file]); |
| 752 manager.assertContextFiles(subProjectA, [subProjectA_file]); |
| 753 } |
| 754 |
571 void test_setRoots_removeFolderWithPubspec() { | 755 void test_setRoots_removeFolderWithPubspec() { |
572 // create a pubspec | 756 // create a pubspec |
573 String pubspecPath = posix.join(projPath, 'pubspec.yaml'); | 757 String pubspecPath = posix.join(projPath, 'pubspec.yaml'); |
574 resourceProvider.newFile(pubspecPath, 'pubspec'); | 758 resourceProvider.newFile(pubspecPath, 'pubspec'); |
575 // add one root - there is a context | 759 // add one root - there is a context |
576 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 760 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
577 expect(manager.currentContextPaths, hasLength(1)); | 761 expect(manager.currentContextPaths, hasLength(1)); |
578 // set empty roots - no contexts | 762 // set empty roots - no contexts |
579 manager.setRoots(<String>[], <String>[], <String, String>{}); | 763 manager.setRoots(<String>[], <String>[], <String, String>{}); |
580 expect(manager.currentContextPaths, hasLength(0)); | 764 expect(manager.currentContextPaths, hasLength(0)); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 // add file in subfolder | 872 // add file in subfolder |
689 String filePath = posix.join(projPath, 'foo', 'bar.dart'); | 873 String filePath = posix.join(projPath, 'foo', 'bar.dart'); |
690 resourceProvider.newFile(filePath, 'contents'); | 874 resourceProvider.newFile(filePath, 'contents'); |
691 // the file was added | 875 // the file was added |
692 return pumpEventQueue().then((_) { | 876 return pumpEventQueue().then((_) { |
693 expect(filePaths, hasLength(1)); | 877 expect(filePaths, hasLength(1)); |
694 expect(filePaths, contains(filePath)); | 878 expect(filePaths, contains(filePath)); |
695 }); | 879 }); |
696 } | 880 } |
697 | 881 |
| 882 test_watch_addPackagespec_toRoot() { |
| 883 // prepare paths |
| 884 String root = '/root'; |
| 885 String rootFile = '$root/root.dart'; |
| 886 String rootPackagespec = '$root/.packages'; |
| 887 // create files |
| 888 resourceProvider.newFile(rootFile, 'library root;'); |
| 889 // set roots |
| 890 manager.setRoots(<String>[root], <String>[], <String, String>{}); |
| 891 manager.assertContextPaths([root]); |
| 892 // verify files |
| 893 manager.assertContextFiles(root, [rootFile]); |
| 894 // add packagespec - still just one root |
| 895 resourceProvider.newFile(rootPackagespec, ''); |
| 896 return pumpEventQueue().then((_) { |
| 897 manager.assertContextPaths([root]); |
| 898 manager.assertContextFiles(root, [rootFile]); |
| 899 // TODO(pquitslund): verify that a new source factory is created -- |
| 900 // likely this will need to happen in a corresponding ServerContextManager
Test. |
| 901 }); |
| 902 } |
| 903 |
| 904 test_watch_addPackagespec_toSubFolder() { |
| 905 // prepare paths |
| 906 String root = '/root'; |
| 907 String rootFile = '$root/root.dart'; |
| 908 String subProject = '$root/sub/aaa'; |
| 909 String subPubspec = '$subProject/.packages'; |
| 910 String subFile = '$subProject/bin/a.dart'; |
| 911 // create files |
| 912 resourceProvider.newFile(rootFile, 'library root;'); |
| 913 resourceProvider.newFile(subFile, 'library a;'); |
| 914 // set roots |
| 915 manager.setRoots(<String>[root], <String>[], <String, String>{}); |
| 916 manager.assertContextPaths([root]); |
| 917 // verify files |
| 918 manager.assertContextFiles(root, [rootFile, subFile]); |
| 919 // add .packages |
| 920 resourceProvider.newFile(subPubspec, ''); |
| 921 return pumpEventQueue().then((_) { |
| 922 manager.assertContextPaths([root, subProject]); |
| 923 manager.assertContextFiles(root, [rootFile]); |
| 924 manager.assertContextFiles(subProject, [subFile]); |
| 925 }); |
| 926 } |
| 927 |
| 928 test_watch_addPackagespec_toSubFolder_ofSubFolder() { |
| 929 // prepare paths |
| 930 String root = '/root'; |
| 931 String rootFile = '$root/root.dart'; |
| 932 String subProject = '$root/sub'; |
| 933 String subPubspec = '$subProject/.packages'; |
| 934 String subFile = '$subProject/bin/sub.dart'; |
| 935 String subSubPubspec = '$subProject/subsub/.packages'; |
| 936 // create files |
| 937 resourceProvider.newFile(rootFile, 'library root;'); |
| 938 resourceProvider.newFile(subPubspec, ''); |
| 939 resourceProvider.newFile(subFile, 'library sub;'); |
| 940 // set roots |
| 941 manager.setRoots(<String>[root], <String>[], <String, String>{}); |
| 942 manager.assertContextPaths([root, subProject]); |
| 943 manager.assertContextFiles(root, [rootFile]); |
| 944 manager.assertContextFiles(subProject, [subFile]); |
| 945 // add pubspec - ignore, because is already in a packagespec-based context |
| 946 resourceProvider.newFile(subSubPubspec, ''); |
| 947 return pumpEventQueue().then((_) { |
| 948 manager.assertContextPaths([root, subProject]); |
| 949 manager.assertContextFiles(root, [rootFile]); |
| 950 manager.assertContextFiles(subProject, [subFile]); |
| 951 }); |
| 952 } |
| 953 |
| 954 test_watch_addPackagespec_toSubFolder_withPubspec() { |
| 955 // prepare paths |
| 956 String root = '/root'; |
| 957 String rootFile = '$root/root.dart'; |
| 958 String subProject = '$root/sub/aaa'; |
| 959 String subPackagespec = '$subProject/.packages'; |
| 960 String subPubspec = '$subProject/pubspec.yaml'; |
| 961 String subFile = '$subProject/bin/a.dart'; |
| 962 // create files |
| 963 resourceProvider.newFile(subPubspec, 'pubspec'); |
| 964 resourceProvider.newFile(rootFile, 'library root;'); |
| 965 resourceProvider.newFile(subFile, 'library a;'); |
| 966 // set roots |
| 967 manager.setRoots(<String>[root], <String>[], <String, String>{}); |
| 968 manager.assertContextPaths([root, subProject]); |
| 969 // verify files |
| 970 manager.assertContextFiles(root, [rootFile]); |
| 971 manager.assertContextFiles(subProject, [subFile]); |
| 972 |
| 973 // add .packages |
| 974 resourceProvider.newFile(subPackagespec, ''); |
| 975 return pumpEventQueue().then((_) { |
| 976 // Should NOT create another context. |
| 977 manager.assertContextPaths([root, subProject]); |
| 978 manager.assertContextFiles(root, [rootFile]); |
| 979 manager.assertContextFiles(subProject, [subFile]); |
| 980 }); |
| 981 } |
| 982 |
698 test_watch_addPubspec_toRoot() { | 983 test_watch_addPubspec_toRoot() { |
699 // prepare paths | 984 // prepare paths |
700 String root = '/root'; | 985 String root = '/root'; |
701 String rootFile = '$root/root.dart'; | 986 String rootFile = '$root/root.dart'; |
702 String rootPubspec = '$root/pubspec.yaml'; | 987 String rootPubspec = '$root/pubspec.yaml'; |
703 // create files | 988 // create files |
704 resourceProvider.newFile(rootFile, 'library root;'); | 989 resourceProvider.newFile(rootFile, 'library root;'); |
705 // set roots | 990 // set roots |
706 manager.setRoots(<String>[root], <String>[], <String, String>{}); | 991 manager.setRoots(<String>[root], <String>[], <String, String>{}); |
707 manager.assertContextPaths([root]); | 992 manager.assertContextPaths([root]); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 expect(projFolder.exists, isTrue); | 1085 expect(projFolder.exists, isTrue); |
801 // delete the folder | 1086 // delete the folder |
802 resourceProvider.deleteFolder(projPath); | 1087 resourceProvider.deleteFolder(projPath); |
803 return pumpEventQueue().then((_) { | 1088 return pumpEventQueue().then((_) { |
804 expect(file.exists, isFalse); | 1089 expect(file.exists, isFalse); |
805 expect(projFolder.exists, isFalse); | 1090 expect(projFolder.exists, isFalse); |
806 return expect(filePaths, hasLength(0)); | 1091 return expect(filePaths, hasLength(0)); |
807 }); | 1092 }); |
808 } | 1093 } |
809 | 1094 |
| 1095 test_watch_deletePackagespec_fromRoot() { |
| 1096 // prepare paths |
| 1097 String root = '/root'; |
| 1098 String rootPubspec = '$root/.packages'; |
| 1099 String rootFile = '$root/root.dart'; |
| 1100 // create files |
| 1101 resourceProvider.newFile(rootPubspec, ''); |
| 1102 resourceProvider.newFile(rootFile, 'library root;'); |
| 1103 // set roots |
| 1104 manager.setRoots(<String>[root], <String>[], <String, String>{}); |
| 1105 manager.assertContextPaths([root]); |
| 1106 manager.assertContextFiles(root, [rootFile]); |
| 1107 // delete the pubspec |
| 1108 resourceProvider.deleteFile(rootPubspec); |
| 1109 return pumpEventQueue().then((_) { |
| 1110 manager.assertContextPaths([root]); |
| 1111 manager.assertContextFiles(root, [rootFile]); |
| 1112 }); |
| 1113 } |
| 1114 |
| 1115 test_watch_deletePackagespec_fromSubFolder() { |
| 1116 // prepare paths |
| 1117 String root = '/root'; |
| 1118 String rootFile = '$root/root.dart'; |
| 1119 String subProject = '$root/sub/aaa'; |
| 1120 String subPubspec = '$subProject/.packages'; |
| 1121 String subFile = '$subProject/bin/a.dart'; |
| 1122 // create files |
| 1123 resourceProvider.newFile(subPubspec, ''); |
| 1124 resourceProvider.newFile(rootFile, 'library root;'); |
| 1125 resourceProvider.newFile(subFile, 'library a;'); |
| 1126 // set roots |
| 1127 manager.setRoots(<String>[root], <String>[], <String, String>{}); |
| 1128 manager.assertContextPaths([root, subProject]); |
| 1129 // verify files |
| 1130 manager.assertContextFiles(root, [rootFile]); |
| 1131 manager.assertContextFiles(subProject, [subFile]); |
| 1132 // delete the pubspec |
| 1133 resourceProvider.deleteFile(subPubspec); |
| 1134 return pumpEventQueue().then((_) { |
| 1135 manager.assertContextPaths([root]); |
| 1136 manager.assertContextFiles(root, [rootFile, subFile]); |
| 1137 }); |
| 1138 } |
| 1139 |
| 1140 test_watch_deletePackagespec_fromSubFolder_withPubspec() { |
| 1141 // prepare paths |
| 1142 String root = '/root'; |
| 1143 String rootFile = '$root/root.dart'; |
| 1144 String subProject = '$root/sub/aaa'; |
| 1145 String subPackagespec = '$subProject/.packages'; |
| 1146 String subPubspec = '$subProject/pubspec.yaml'; |
| 1147 String subFile = '$subProject/bin/a.dart'; |
| 1148 // create files |
| 1149 resourceProvider.newFile(subPackagespec, ''); |
| 1150 resourceProvider.newFile(subPubspec, 'pubspec'); |
| 1151 resourceProvider.newFile(rootFile, 'library root;'); |
| 1152 resourceProvider.newFile(subFile, 'library a;'); |
| 1153 // set roots |
| 1154 manager.setRoots(<String>[root], <String>[], <String, String>{}); |
| 1155 manager.assertContextPaths([root, subProject]); |
| 1156 // verify files |
| 1157 manager.assertContextFiles(root, [rootFile]); |
| 1158 manager.assertContextFiles(subProject, [subFile]); |
| 1159 // delete the packagespec |
| 1160 resourceProvider.deleteFile(subPackagespec); |
| 1161 return pumpEventQueue().then((_) { |
| 1162 // Should NOT merge |
| 1163 manager.assertContextPaths([root, subProject]); |
| 1164 manager.assertContextFiles(subProject, [subFile]); |
| 1165 }); |
| 1166 } |
| 1167 |
810 test_watch_deletePubspec_fromRoot() { | 1168 test_watch_deletePubspec_fromRoot() { |
811 // prepare paths | 1169 // prepare paths |
812 String root = '/root'; | 1170 String root = '/root'; |
813 String rootPubspec = '$root/pubspec.yaml'; | 1171 String rootPubspec = '$root/pubspec.yaml'; |
814 String rootFile = '$root/root.dart'; | 1172 String rootFile = '$root/root.dart'; |
815 // create files | 1173 // create files |
816 resourceProvider.newFile(rootPubspec, 'pubspec'); | 1174 resourceProvider.newFile(rootPubspec, 'pubspec'); |
817 resourceProvider.newFile(rootFile, 'library root;'); | 1175 resourceProvider.newFile(rootFile, 'library root;'); |
818 // set roots | 1176 // set roots |
819 manager.setRoots(<String>[root], <String>[], <String, String>{}); | 1177 manager.setRoots(<String>[root], <String>[], <String, String>{}); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 File resource = resourceProvider.getResource(path); | 1334 File resource = resourceProvider.getResource(path); |
977 packageMapProvider.modificationTimes[path] = resource.modificationStamp; | 1335 packageMapProvider.modificationTimes[path] = resource.modificationStamp; |
978 } | 1336 } |
979 // This should cause the new package map to be picked up, by executing | 1337 // This should cause the new package map to be picked up, by executing |
980 // computePackageMap just one additional time. | 1338 // computePackageMap just one additional time. |
981 await pumpEventQueue(); | 1339 await pumpEventQueue(); |
982 _checkPackageMap(projPath, equals(packageMapProvider.packageMap)); | 1340 _checkPackageMap(projPath, equals(packageMapProvider.packageMap)); |
983 expect(packageMapProvider.computeCount, 2); | 1341 expect(packageMapProvider.computeCount, 2); |
984 } | 1342 } |
985 | 1343 |
| 1344 test_watch_modifyPackagespec() { |
| 1345 String packagesPath = '$projPath/.packages'; |
| 1346 String filePath = '$projPath/bin/main.dart'; |
| 1347 |
| 1348 resourceProvider.newFile(packagesPath, ''); |
| 1349 resourceProvider.newFile(filePath, 'library main;'); |
| 1350 |
| 1351 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| 1352 |
| 1353 Map<String, int> filePaths = manager.currentContextFilePaths[projPath]; |
| 1354 expect(filePaths, hasLength(1)); |
| 1355 expect(filePaths, contains(filePath)); |
| 1356 Packages packages = manager.currentContextPackagespecs[projPath]; |
| 1357 expect(packages.packages, isEmpty); |
| 1358 |
| 1359 // update .packages |
| 1360 manager.now++; |
| 1361 resourceProvider.modifyFile(packagesPath, 'main:./lib/'); |
| 1362 return pumpEventQueue().then((_) { |
| 1363 // verify new package info |
| 1364 packages = manager.currentContextPackagespecs[projPath]; |
| 1365 expect(packages.packages, unorderedEquals(['main'])); |
| 1366 }); |
| 1367 } |
| 1368 |
986 /** | 1369 /** |
987 * Verify that package URI's for source files in [path] will be resolved | 1370 * Verify that package URI's for source files in [path] will be resolved |
988 * using a package map matching [expectation]. | 1371 * using a package map matching [expectation]. |
989 */ | 1372 */ |
990 void _checkPackageMap(String path, expectation) { | 1373 void _checkPackageMap(String path, expectation) { |
991 UriResolver resolver = manager.currentContextPackageUriResolvers[path]; | 1374 UriResolver resolver = manager.currentContextPackageUriResolvers[path]; |
992 Map<String, List<Folder>> packageMap = | 1375 Map<String, List<Folder>> packageMap = |
993 resolver is PackageMapUriResolver ? resolver.packageMap : null; | 1376 resolver is PackageMapUriResolver ? resolver.packageMap : null; |
994 expect(packageMap, expectation); | 1377 expect(packageMap, expectation); |
995 } | 1378 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 */ | 1417 */ |
1035 final Map<String, Set<Source>> currentContextSources = <String, Set<Source>>{ | 1418 final Map<String, Set<Source>> currentContextSources = <String, Set<Source>>{ |
1036 }; | 1419 }; |
1037 | 1420 |
1038 /** | 1421 /** |
1039 * Map from context to package URI resolver. | 1422 * Map from context to package URI resolver. |
1040 */ | 1423 */ |
1041 final Map<String, UriResolver> currentContextPackageUriResolvers = | 1424 final Map<String, UriResolver> currentContextPackageUriResolvers = |
1042 <String, UriResolver>{}; | 1425 <String, UriResolver>{}; |
1043 | 1426 |
| 1427 /** |
| 1428 * Map from context to packages object. |
| 1429 */ |
| 1430 final Map<String, Packages> currentContextPackagespecs = <String, Packages>{}; |
| 1431 |
1044 TestContextManager(MemoryResourceProvider resourceProvider, | 1432 TestContextManager(MemoryResourceProvider resourceProvider, |
1045 ResolverProvider packageResolverProvider, | 1433 ResolverProvider packageResolverProvider, |
1046 OptimizingPubPackageMapProvider packageMapProvider) | 1434 OptimizingPubPackageMapProvider packageMapProvider) |
1047 : super(resourceProvider, packageResolverProvider, packageMapProvider, | 1435 : super(resourceProvider, packageResolverProvider, packageMapProvider, |
1048 InstrumentationService.NULL_SERVICE); | 1436 InstrumentationService.NULL_SERVICE); |
1049 | 1437 |
1050 /** | 1438 /** |
1051 * Iterable of the paths to contexts that currently exist. | 1439 * Iterable of the paths to contexts that currently exist. |
1052 */ | 1440 */ |
1053 Iterable<String> get currentContextPaths => currentContextTimestamps.keys; | 1441 Iterable<String> get currentContextPaths => currentContextTimestamps.keys; |
1054 | 1442 |
1055 @override | 1443 @override |
1056 AnalysisContext addContext(Folder folder, UriResolver packageUriResolver) { | 1444 AnalysisContext addContext( |
| 1445 Folder folder, UriResolver packageUriResolver, Packages packages) { |
1057 String path = folder.path; | 1446 String path = folder.path; |
1058 expect(currentContextPaths, isNot(contains(path))); | 1447 expect(currentContextPaths, isNot(contains(path))); |
1059 currentContextTimestamps[path] = now; | 1448 currentContextTimestamps[path] = now; |
1060 currentContextFilePaths[path] = <String, int>{}; | 1449 currentContextFilePaths[path] = <String, int>{}; |
1061 currentContextSources[path] = new HashSet<Source>(); | 1450 currentContextSources[path] = new HashSet<Source>(); |
1062 currentContextPackageUriResolvers[path] = packageUriResolver; | 1451 currentContextPackageUriResolvers[path] = packageUriResolver; |
| 1452 currentContextPackagespecs[path] = packages; |
1063 currentContext = AnalysisEngine.instance.createAnalysisContext(); | 1453 currentContext = AnalysisEngine.instance.createAnalysisContext(); |
1064 currentContext.sourceFactory = new SourceFactory( | 1454 List<UriResolver> resolvers = [new FileUriResolver()]; |
1065 packageUriResolver == null ? [] : [packageUriResolver]); | 1455 if (packageUriResolver != null) { |
| 1456 resolvers.add(packageUriResolver); |
| 1457 } |
| 1458 currentContext.sourceFactory = new SourceFactory(resolvers, packages); |
1066 return currentContext; | 1459 return currentContext; |
1067 } | 1460 } |
1068 | 1461 |
1069 @override | 1462 @override |
1070 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { | 1463 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { |
1071 Map<String, int> filePaths = currentContextFilePaths[contextFolder.path]; | 1464 Map<String, int> filePaths = currentContextFilePaths[contextFolder.path]; |
1072 Set<Source> sources = currentContextSources[contextFolder.path]; | 1465 Set<Source> sources = currentContextSources[contextFolder.path]; |
1073 | 1466 |
1074 for (Source source in changeSet.addedSources) { | 1467 for (Source source in changeSet.addedSources) { |
1075 expect(filePaths, isNot(contains(source.fullName))); | 1468 expect(filePaths, isNot(contains(source.fullName))); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 // Emacs creates dummy links to track the fact that a file is open for | 1510 // Emacs creates dummy links to track the fact that a file is open for |
1118 // editing and has unsaved changes (e.g. having unsaved changes to | 1511 // editing and has unsaved changes (e.g. having unsaved changes to |
1119 // 'foo.dart' causes a link '.#foo.dart' to be created, which points to the | 1512 // 'foo.dart' causes a link '.#foo.dart' to be created, which points to the |
1120 // non-existent file 'username@hostname.pid'. To avoid these dummy links | 1513 // non-existent file 'username@hostname.pid'. To avoid these dummy links |
1121 // causing the analyzer to thrash, just ignore links to non-existent files. | 1514 // causing the analyzer to thrash, just ignore links to non-existent files. |
1122 return file.exists; | 1515 return file.exists; |
1123 } | 1516 } |
1124 | 1517 |
1125 @override | 1518 @override |
1126 void updateContextPackageUriResolver( | 1519 void updateContextPackageUriResolver( |
1127 Folder contextFolder, UriResolver packageUriResolver) { | 1520 Folder contextFolder, UriResolver packageUriResolver, Packages packages) { |
1128 currentContextPackageUriResolvers[contextFolder.path] = packageUriResolver; | 1521 currentContextPackageUriResolvers[contextFolder.path] = packageUriResolver; |
| 1522 currentContextPackagespecs[contextFolder.path] = packages; |
1129 } | 1523 } |
1130 } | 1524 } |
1131 | 1525 |
1132 /** | 1526 /** |
1133 * A [Source] that knows it's [fullName]. | 1527 * A [Source] that knows it's [fullName]. |
1134 */ | 1528 */ |
1135 class TestSource implements Source { | 1529 class TestSource implements Source { |
1136 TestSource(); | 1530 TestSource(); |
1137 | 1531 |
1138 @override | 1532 @override |
1139 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 1533 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
1140 } | 1534 } |
1141 | 1535 |
1142 class TestUriResolver extends UriResolver { | 1536 class TestUriResolver extends UriResolver { |
1143 Map<Uri, Source> uriMap; | 1537 Map<Uri, Source> uriMap; |
1144 | 1538 |
1145 TestUriResolver(this.uriMap); | 1539 TestUriResolver(this.uriMap); |
1146 | 1540 |
1147 @override | 1541 @override |
1148 Source resolveAbsolute(Uri uri) { | 1542 Source resolveAbsolute(Uri uri) { |
1149 return uriMap[uri]; | 1543 return uriMap[uri]; |
1150 } | 1544 } |
1151 } | 1545 } |
OLD | NEW |