| 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 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 // Change the package map dependency so that the packageMapProvider is | 1340 // Change the package map dependency so that the packageMapProvider is |
| 1341 // re-run, and arrange for it to return null from computePackageMap(). | 1341 // re-run, and arrange for it to return null from computePackageMap(). |
| 1342 packageMapProvider.packageMap = null; | 1342 packageMapProvider.packageMap = null; |
| 1343 resourceProvider.modifyFile(dependencyPath, 'new contents'); | 1343 resourceProvider.modifyFile(dependencyPath, 'new contents'); |
| 1344 return pumpEventQueue().then((_) { | 1344 return pumpEventQueue().then((_) { |
| 1345 // The package map should have been changed to null. | 1345 // The package map should have been changed to null. |
| 1346 _checkPackageMap(projPath, isNull); | 1346 _checkPackageMap(projPath, isNull); |
| 1347 }); | 1347 }); |
| 1348 } | 1348 } |
| 1349 | 1349 |
| 1350 test_watch_modifyPackageMapDependency_outsideProject() { | |
| 1351 // create a dependency file | |
| 1352 String dependencyPath = '/my/other/dep'; | |
| 1353 resourceProvider.newFile(dependencyPath, 'contents'); | |
| 1354 packageMapProvider.dependencies.add(dependencyPath); | |
| 1355 // create a Dart file | |
| 1356 String dartFilePath = posix.join(projPath, 'main.dart'); | |
| 1357 resourceProvider.newFile(dartFilePath, 'contents'); | |
| 1358 // the created context has the expected empty package map | |
| 1359 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | |
| 1360 _checkPackageMap(projPath, isEmpty); | |
| 1361 // configure package map | |
| 1362 String packagePath = '/package/foo'; | |
| 1363 resourceProvider.newFolder(packagePath); | |
| 1364 packageMapProvider.packageMap = {'foo': projPath}; | |
| 1365 // Changing a .dart file in the project shouldn't cause a new | |
| 1366 // package map to be picked up. | |
| 1367 resourceProvider.modifyFile(dartFilePath, 'new contents'); | |
| 1368 return pumpEventQueue().then((_) { | |
| 1369 _checkPackageMap(projPath, isEmpty); | |
| 1370 // However, changing the package map dependency should. | |
| 1371 resourceProvider.modifyFile(dependencyPath, 'new contents'); | |
| 1372 return pumpEventQueue().then((_) { | |
| 1373 _checkPackageMap(projPath, equals(packageMapProvider.packageMap)); | |
| 1374 }); | |
| 1375 }); | |
| 1376 } | |
| 1377 | |
| 1378 test_watch_modifyPackagespec() { | 1350 test_watch_modifyPackagespec() { |
| 1379 String packagesPath = '$projPath/.packages'; | 1351 String packagesPath = '$projPath/.packages'; |
| 1380 String filePath = '$projPath/bin/main.dart'; | 1352 String filePath = '$projPath/bin/main.dart'; |
| 1381 | 1353 |
| 1382 resourceProvider.newFile(packagesPath, ''); | 1354 resourceProvider.newFile(packagesPath, ''); |
| 1383 resourceProvider.newFile(filePath, 'library main;'); | 1355 resourceProvider.newFile(filePath, 'library main;'); |
| 1384 | 1356 |
| 1385 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 1357 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| 1386 | 1358 |
| 1387 Map<String, int> filePaths = callbacks.currentContextFilePaths[projPath]; | 1359 Map<String, int> filePaths = callbacks.currentContextFilePaths[projPath]; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1562 class TestUriResolver extends UriResolver { | 1534 class TestUriResolver extends UriResolver { |
| 1563 Map<Uri, Source> uriMap; | 1535 Map<Uri, Source> uriMap; |
| 1564 | 1536 |
| 1565 TestUriResolver(this.uriMap); | 1537 TestUriResolver(this.uriMap); |
| 1566 | 1538 |
| 1567 @override | 1539 @override |
| 1568 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 1540 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 1569 return uriMap[uri]; | 1541 return uriMap[uri]; |
| 1570 } | 1542 } |
| 1571 } | 1543 } |
| OLD | NEW |