| 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 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 // exclude "bbb/" | 1006 // exclude "bbb/" |
| 1007 manager.setRoots(<String>[project], <String>[folderB], <String, String>{}); | 1007 manager.setRoots(<String>[project], <String>[folderB], <String, String>{}); |
| 1008 callbacks.assertContextPaths([project]); | 1008 callbacks.assertContextPaths([project]); |
| 1009 callbacks.assertContextFiles(project, [fileA]); | 1009 callbacks.assertContextFiles(project, [fileA]); |
| 1010 // stop excluding "bbb/" | 1010 // stop excluding "bbb/" |
| 1011 manager.setRoots(<String>[project], <String>[], <String, String>{}); | 1011 manager.setRoots(<String>[project], <String>[], <String, String>{}); |
| 1012 callbacks.assertContextPaths([project]); | 1012 callbacks.assertContextPaths([project]); |
| 1013 callbacks.assertContextFiles(project, [fileA, fileB]); | 1013 callbacks.assertContextFiles(project, [fileA, fileB]); |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 void test_setRoots_ignoreDocFolder() { |
| 1017 String project = '/project'; |
| 1018 String fileA = '$project/foo.dart'; |
| 1019 String fileB = '$project/doc/bar.dart'; |
| 1020 resourceProvider.newFile(fileA, ''); |
| 1021 resourceProvider.newFile(fileB, ''); |
| 1022 manager.setRoots(<String>[project], <String>[], <String, String>{}); |
| 1023 callbacks.assertContextPaths([project]); |
| 1024 callbacks.assertContextFiles(project, [fileA]); |
| 1025 } |
| 1026 |
| 1016 void test_setRoots_newFolderWithPackageRoot() { | 1027 void test_setRoots_newFolderWithPackageRoot() { |
| 1017 String packageRootPath = '/package'; | 1028 String packageRootPath = '/package'; |
| 1018 manager.setRoots(<String>[projPath], <String>[], | 1029 manager.setRoots(<String>[projPath], <String>[], |
| 1019 <String, String>{projPath: packageRootPath}); | 1030 <String, String>{projPath: packageRootPath}); |
| 1020 _checkPackageRoot(projPath, equals(packageRootPath)); | 1031 _checkPackageRoot(projPath, equals(packageRootPath)); |
| 1021 } | 1032 } |
| 1022 | 1033 |
| 1023 void test_setRoots_newlyAddedFoldersGetProperPackageMap() { | 1034 void test_setRoots_newlyAddedFoldersGetProperPackageMap() { |
| 1024 String packagePath = '/package/foo'; | 1035 String packagePath = '/package/foo'; |
| 1025 Folder packageFolder = resourceProvider.newFolder(packagePath); | 1036 Folder packageFolder = resourceProvider.newFolder(packagePath); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 callbacks.assertContextPaths([project]); | 1301 callbacks.assertContextPaths([project]); |
| 1291 callbacks.assertContextFiles(project, [fileA]); | 1302 callbacks.assertContextFiles(project, [fileA]); |
| 1292 // add a file, ignored as excluded | 1303 // add a file, ignored as excluded |
| 1293 resourceProvider.newFile(fileB, 'library b;'); | 1304 resourceProvider.newFile(fileB, 'library b;'); |
| 1294 return pumpEventQueue().then((_) { | 1305 return pumpEventQueue().then((_) { |
| 1295 callbacks.assertContextPaths([project]); | 1306 callbacks.assertContextPaths([project]); |
| 1296 callbacks.assertContextFiles(project, [fileA]); | 1307 callbacks.assertContextFiles(project, [fileA]); |
| 1297 }); | 1308 }); |
| 1298 } | 1309 } |
| 1299 | 1310 |
| 1311 test_watch_addFile_inDocFolder() { |
| 1312 // prepare paths |
| 1313 String project = '/project'; |
| 1314 String fileA = '$project/a.dart'; |
| 1315 String fileB = '$project/doc/b.dart'; |
| 1316 // create files |
| 1317 resourceProvider.newFile(fileA, ''); |
| 1318 // set roots |
| 1319 manager.setRoots(<String>[project], <String>[], <String, String>{}); |
| 1320 callbacks.assertContextPaths([project]); |
| 1321 callbacks.assertContextFiles(project, [fileA]); |
| 1322 // add a "doc" file, it is ignored |
| 1323 resourceProvider.newFile(fileB, ''); |
| 1324 return pumpEventQueue().then((_) { |
| 1325 callbacks.assertContextPaths([project]); |
| 1326 callbacks.assertContextFiles(project, [fileA]); |
| 1327 }); |
| 1328 } |
| 1329 |
| 1300 test_watch_addFile_pathContainsDotFile() async { | 1330 test_watch_addFile_pathContainsDotFile() async { |
| 1301 // If a file is added and the path to it (relative to the context root) | 1331 // If a file is added and the path to it (relative to the context root) |
| 1302 // contains a folder whose name begins with '.', then the file is ignored. | 1332 // contains a folder whose name begins with '.', then the file is ignored. |
| 1303 String project = '/project'; | 1333 String project = '/project'; |
| 1304 String fileA = '$project/foo.dart'; | 1334 String fileA = '$project/foo.dart'; |
| 1305 String fileB = '$project/.pub/bar.dart'; | 1335 String fileB = '$project/.pub/bar.dart'; |
| 1306 resourceProvider.newFile(fileA, ''); | 1336 resourceProvider.newFile(fileA, ''); |
| 1307 manager.setRoots(<String>[project], <String>[], <String, String>{}); | 1337 manager.setRoots(<String>[project], <String>[], <String, String>{}); |
| 1308 callbacks.assertContextPaths([project]); | 1338 callbacks.assertContextPaths([project]); |
| 1309 callbacks.assertContextFiles(project, [fileA]); | 1339 callbacks.assertContextFiles(project, [fileA]); |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1940 class TestUriResolver extends UriResolver { | 1970 class TestUriResolver extends UriResolver { |
| 1941 Map<Uri, Source> uriMap; | 1971 Map<Uri, Source> uriMap; |
| 1942 | 1972 |
| 1943 TestUriResolver(this.uriMap); | 1973 TestUriResolver(this.uriMap); |
| 1944 | 1974 |
| 1945 @override | 1975 @override |
| 1946 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 1976 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 1947 return uriMap[uri]; | 1977 return uriMap[uri]; |
| 1948 } | 1978 } |
| 1949 } | 1979 } |
| OLD | NEW |