| 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/lib/doc/bar.dart'; |
| 1020 String fileC = '$project/doc/bar.dart'; |
| 1021 resourceProvider.newFile(fileA, ''); |
| 1022 resourceProvider.newFile(fileB, ''); |
| 1023 resourceProvider.newFile(fileC, ''); |
| 1024 manager.setRoots(<String>[project], <String>[], <String, String>{}); |
| 1025 callbacks.assertContextPaths([project]); |
| 1026 callbacks.assertContextFiles(project, [fileA, fileB]); |
| 1027 } |
| 1028 |
| 1016 void test_setRoots_newFolderWithPackageRoot() { | 1029 void test_setRoots_newFolderWithPackageRoot() { |
| 1017 String packageRootPath = '/package'; | 1030 String packageRootPath = '/package'; |
| 1018 manager.setRoots(<String>[projPath], <String>[], | 1031 manager.setRoots(<String>[projPath], <String>[], |
| 1019 <String, String>{projPath: packageRootPath}); | 1032 <String, String>{projPath: packageRootPath}); |
| 1020 _checkPackageRoot(projPath, equals(packageRootPath)); | 1033 _checkPackageRoot(projPath, equals(packageRootPath)); |
| 1021 } | 1034 } |
| 1022 | 1035 |
| 1023 void test_setRoots_newlyAddedFoldersGetProperPackageMap() { | 1036 void test_setRoots_newlyAddedFoldersGetProperPackageMap() { |
| 1024 String packagePath = '/package/foo'; | 1037 String packagePath = '/package/foo'; |
| 1025 Folder packageFolder = resourceProvider.newFolder(packagePath); | 1038 Folder packageFolder = resourceProvider.newFolder(packagePath); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 callbacks.assertContextPaths([project]); | 1303 callbacks.assertContextPaths([project]); |
| 1291 callbacks.assertContextFiles(project, [fileA]); | 1304 callbacks.assertContextFiles(project, [fileA]); |
| 1292 // add a file, ignored as excluded | 1305 // add a file, ignored as excluded |
| 1293 resourceProvider.newFile(fileB, 'library b;'); | 1306 resourceProvider.newFile(fileB, 'library b;'); |
| 1294 return pumpEventQueue().then((_) { | 1307 return pumpEventQueue().then((_) { |
| 1295 callbacks.assertContextPaths([project]); | 1308 callbacks.assertContextPaths([project]); |
| 1296 callbacks.assertContextFiles(project, [fileA]); | 1309 callbacks.assertContextFiles(project, [fileA]); |
| 1297 }); | 1310 }); |
| 1298 } | 1311 } |
| 1299 | 1312 |
| 1313 test_watch_addFile_inDocFolder_inner() { |
| 1314 // prepare paths |
| 1315 String project = '/project'; |
| 1316 String fileA = '$project/a.dart'; |
| 1317 String fileB = '$project/lib/doc/b.dart'; |
| 1318 // create files |
| 1319 resourceProvider.newFile(fileA, ''); |
| 1320 // set roots |
| 1321 manager.setRoots(<String>[project], <String>[], <String, String>{}); |
| 1322 callbacks.assertContextPaths([project]); |
| 1323 callbacks.assertContextFiles(project, [fileA]); |
| 1324 // add a "lib/doc" file, it is not ignored |
| 1325 resourceProvider.newFile(fileB, ''); |
| 1326 return pumpEventQueue().then((_) { |
| 1327 callbacks.assertContextPaths([project]); |
| 1328 callbacks.assertContextFiles(project, [fileA, fileB]); |
| 1329 }); |
| 1330 } |
| 1331 |
| 1332 test_watch_addFile_inDocFolder_topLevel() { |
| 1333 // prepare paths |
| 1334 String project = '/project'; |
| 1335 String fileA = '$project/a.dart'; |
| 1336 String fileB = '$project/doc/b.dart'; |
| 1337 // create files |
| 1338 resourceProvider.newFile(fileA, ''); |
| 1339 // set roots |
| 1340 manager.setRoots(<String>[project], <String>[], <String, String>{}); |
| 1341 callbacks.assertContextPaths([project]); |
| 1342 callbacks.assertContextFiles(project, [fileA]); |
| 1343 // add a "doc" file, it is ignored |
| 1344 resourceProvider.newFile(fileB, ''); |
| 1345 return pumpEventQueue().then((_) { |
| 1346 callbacks.assertContextPaths([project]); |
| 1347 callbacks.assertContextFiles(project, [fileA]); |
| 1348 }); |
| 1349 } |
| 1350 |
| 1300 test_watch_addFile_pathContainsDotFile() async { | 1351 test_watch_addFile_pathContainsDotFile() async { |
| 1301 // If a file is added and the path to it (relative to the context root) | 1352 // 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. | 1353 // contains a folder whose name begins with '.', then the file is ignored. |
| 1303 String project = '/project'; | 1354 String project = '/project'; |
| 1304 String fileA = '$project/foo.dart'; | 1355 String fileA = '$project/foo.dart'; |
| 1305 String fileB = '$project/.pub/bar.dart'; | 1356 String fileB = '$project/.pub/bar.dart'; |
| 1306 resourceProvider.newFile(fileA, ''); | 1357 resourceProvider.newFile(fileA, ''); |
| 1307 manager.setRoots(<String>[project], <String>[], <String, String>{}); | 1358 manager.setRoots(<String>[project], <String>[], <String, String>{}); |
| 1308 callbacks.assertContextPaths([project]); | 1359 callbacks.assertContextPaths([project]); |
| 1309 callbacks.assertContextFiles(project, [fileA]); | 1360 callbacks.assertContextFiles(project, [fileA]); |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1940 class TestUriResolver extends UriResolver { | 1991 class TestUriResolver extends UriResolver { |
| 1941 Map<Uri, Source> uriMap; | 1992 Map<Uri, Source> uriMap; |
| 1942 | 1993 |
| 1943 TestUriResolver(this.uriMap); | 1994 TestUriResolver(this.uriMap); |
| 1944 | 1995 |
| 1945 @override | 1996 @override |
| 1946 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 1997 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 1947 return uriMap[uri]; | 1998 return uriMap[uri]; |
| 1948 } | 1999 } |
| 1949 } | 2000 } |
| OLD | NEW |