| 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'; |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 // Change the package map dependency so that the packageMapProvider is | 851 // Change the package map dependency so that the packageMapProvider is |
| 852 // re-run, and arrange for it to return null from computePackageMap(). | 852 // re-run, and arrange for it to return null from computePackageMap(). |
| 853 packageMapProvider.packageMap = null; | 853 packageMapProvider.packageMap = null; |
| 854 resourceProvider.modifyFile(dependencyPath, 'new contents'); | 854 resourceProvider.modifyFile(dependencyPath, 'new contents'); |
| 855 return pumpEventQueue().then((_) { | 855 return pumpEventQueue().then((_) { |
| 856 // The package map should have been changed to null. | 856 // The package map should have been changed to null. |
| 857 _checkPackageMap(projPath, isNull); | 857 _checkPackageMap(projPath, isNull); |
| 858 }); | 858 }); |
| 859 } | 859 } |
| 860 | 860 |
| 861 test_watch_modifyPackageMapDependency_outsideProject() { |
| 862 // create a dependency file |
| 863 String dependencyPath = '/my/other/dep'; |
| 864 resourceProvider.newFile(dependencyPath, 'contents'); |
| 865 packageMapProvider.dependencies.add(dependencyPath); |
| 866 // create a Dart file |
| 867 String dartFilePath = posix.join(projPath, 'main.dart'); |
| 868 resourceProvider.newFile(dartFilePath, 'contents'); |
| 869 // the created context has the expected empty package map |
| 870 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| 871 _checkPackageMap(projPath, isEmpty); |
| 872 // configure package map |
| 873 String packagePath = '/package/foo'; |
| 874 resourceProvider.newFolder(packagePath); |
| 875 packageMapProvider.packageMap = {'foo': projPath}; |
| 876 // Changing a .dart file in the project shouldn't cause a new |
| 877 // package map to be picked up. |
| 878 resourceProvider.modifyFile(dartFilePath, 'new contents'); |
| 879 return pumpEventQueue().then((_) { |
| 880 _checkPackageMap(projPath, isEmpty); |
| 881 // However, changing the package map dependency should. |
| 882 resourceProvider.modifyFile(dependencyPath, 'new contents'); |
| 883 return pumpEventQueue().then((_) { |
| 884 _checkPackageMap(projPath, equals(packageMapProvider.packageMap)); |
| 885 }); |
| 886 }); |
| 887 } |
| 888 |
| 861 test_watch_modifyPackageMapDependency_redundantly() async { | 889 test_watch_modifyPackageMapDependency_redundantly() async { |
| 862 // Create two dependency files | 890 // Create two dependency files |
| 863 String dependencyPath1 = posix.join(projPath, 'dep1'); | 891 String dependencyPath1 = posix.join(projPath, 'dep1'); |
| 864 String dependencyPath2 = posix.join(projPath, 'dep2'); | 892 String dependencyPath2 = posix.join(projPath, 'dep2'); |
| 865 resourceProvider.newFile(dependencyPath1, 'contents'); | 893 resourceProvider.newFile(dependencyPath1, 'contents'); |
| 866 resourceProvider.newFile(dependencyPath2, 'contents'); | 894 resourceProvider.newFile(dependencyPath2, 'contents'); |
| 867 packageMapProvider.dependencies.add(dependencyPath1); | 895 packageMapProvider.dependencies.add(dependencyPath1); |
| 868 packageMapProvider.dependencies.add(dependencyPath2); | 896 packageMapProvider.dependencies.add(dependencyPath2); |
| 869 // Create a dart file | 897 // Create a dart file |
| 870 String dartFilePath = posix.join(projPath, 'main.dart'); | 898 String dartFilePath = posix.join(projPath, 'main.dart'); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 // causing the analyzer to thrash, just ignore links to non-existent files. | 1059 // causing the analyzer to thrash, just ignore links to non-existent files. |
| 1032 return file.exists; | 1060 return file.exists; |
| 1033 } | 1061 } |
| 1034 | 1062 |
| 1035 @override | 1063 @override |
| 1036 void updateContextPackageUriResolver( | 1064 void updateContextPackageUriResolver( |
| 1037 Folder contextFolder, UriResolver packageUriResolver) { | 1065 Folder contextFolder, UriResolver packageUriResolver) { |
| 1038 currentContextPackageUriResolvers[contextFolder.path] = packageUriResolver; | 1066 currentContextPackageUriResolvers[contextFolder.path] = packageUriResolver; |
| 1039 } | 1067 } |
| 1040 } | 1068 } |
| OLD | NEW |