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:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 void test_setRoots_newlyAddedFoldersGetProperPackageMap() { | 930 void test_setRoots_newlyAddedFoldersGetProperPackageMap() { |
931 String packagePath = '/package/foo'; | 931 String packagePath = '/package/foo'; |
932 Folder packageFolder = resourceProvider.newFolder(packagePath); | 932 Folder packageFolder = resourceProvider.newFolder(packagePath); |
933 packageMapProvider.packageMap = { | 933 packageMapProvider.packageMap = { |
934 'foo': [packageFolder] | 934 'foo': [packageFolder] |
935 }; | 935 }; |
936 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 936 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
937 _checkPackageMap(projPath, equals(packageMapProvider.packageMap)); | 937 _checkPackageMap(projPath, equals(packageMapProvider.packageMap)); |
938 } | 938 } |
939 | 939 |
| 940 void test_setRoots_noContext_inDotFolder() { |
| 941 String pubspecPath = posix.join(projPath, '.pub', 'pubspec.yaml'); |
| 942 resourceProvider.newFile(pubspecPath, 'name: test'); |
| 943 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| 944 // verify |
| 945 expect(callbacks.currentContextPaths, hasLength(1)); |
| 946 expect(callbacks.currentContextPaths, contains(projPath)); |
| 947 expect(callbacks.currentContextFilePaths[projPath], hasLength(0)); |
| 948 } |
| 949 |
| 950 void test_setRoots_noContext_inPackagesFolder() { |
| 951 String pubspecPath = posix.join(projPath, 'packages', 'pubspec.yaml'); |
| 952 resourceProvider.newFile(pubspecPath, 'name: test'); |
| 953 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| 954 // verify |
| 955 expect(callbacks.currentContextPaths, hasLength(1)); |
| 956 expect(callbacks.currentContextPaths, contains(projPath)); |
| 957 expect(callbacks.currentContextFilePaths[projPath], hasLength(0)); |
| 958 } |
| 959 |
940 void test_setRoots_packageResolver() { | 960 void test_setRoots_packageResolver() { |
941 Uri uri = Uri.parse('package:foo/foo.dart'); | 961 Uri uri = Uri.parse('package:foo/foo.dart'); |
942 Source source = new TestSource(); | 962 Source source = new TestSource(); |
943 packageResolver = new TestUriResolver({uri: source}); | 963 packageResolver = new TestUriResolver({uri: source}); |
944 String filePath = posix.join(projPath, 'foo.dart'); | 964 String filePath = posix.join(projPath, 'foo.dart'); |
945 resourceProvider.newFile(filePath, 'contents'); | 965 resourceProvider.newFile(filePath, 'contents'); |
946 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 966 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
947 | 967 |
948 List<AnalysisContext> contextsInAnalysisRoot = | 968 List<AnalysisContext> contextsInAnalysisRoot = |
949 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath)); | 969 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath)); |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1814 class TestUriResolver extends UriResolver { | 1834 class TestUriResolver extends UriResolver { |
1815 Map<Uri, Source> uriMap; | 1835 Map<Uri, Source> uriMap; |
1816 | 1836 |
1817 TestUriResolver(this.uriMap); | 1837 TestUriResolver(this.uriMap); |
1818 | 1838 |
1819 @override | 1839 @override |
1820 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 1840 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
1821 return uriMap[uri]; | 1841 return uriMap[uri]; |
1822 } | 1842 } |
1823 } | 1843 } |
OLD | NEW |