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 context.directory.manager; | 5 library context.directory.manager; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 } else { | 431 } else { |
432 beginComputePackageMap(); | 432 beginComputePackageMap(); |
433 OptimizingPubPackageMapInfo packageMapInfo; | 433 OptimizingPubPackageMapInfo packageMapInfo; |
434 ServerPerformanceStatistics.pub.makeCurrentWhile(() { | 434 ServerPerformanceStatistics.pub.makeCurrentWhile(() { |
435 packageMapInfo = | 435 packageMapInfo = |
436 _packageMapProvider.computePackageMap(folder, info.packageMapInfo); | 436 _packageMapProvider.computePackageMap(folder, info.packageMapInfo); |
437 }); | 437 }); |
438 endComputePackageMap(); | 438 endComputePackageMap(); |
439 for (String dependencyPath in packageMapInfo.dependencies) { | 439 for (String dependencyPath in packageMapInfo.dependencies) { |
440 Resource resource = resourceProvider.getResource(dependencyPath); | 440 Resource resource = resourceProvider.getResource(dependencyPath); |
441 if (resource is File && resource.exists) { | 441 if (resource is File) { |
442 info.dependencySubscriptions.add(resource.changes | 442 StreamSubscription<WatchEvent> subscription; |
443 .listen((WatchEvent event) { | 443 subscription = resource.changes.listen((WatchEvent event) { |
444 if (info.packageMapInfo != null && | 444 if (info.packageMapInfo != null && |
445 info.packageMapInfo.isChangedDependency( | 445 info.packageMapInfo.isChangedDependency( |
446 dependencyPath, resourceProvider)) { | 446 dependencyPath, resourceProvider)) { |
447 _recomputePackageUriResolver(info); | 447 _recomputePackageUriResolver(info); |
448 } | 448 } |
449 })); | 449 }, onError: (error, StackTrace stackTrace) { |
| 450 // Gracefully degrade if file is or becomes unwatchable |
| 451 _instrumentationService.logException(error, stackTrace); |
| 452 subscription.cancel(); |
| 453 info.dependencySubscriptions.remove(subscription); |
| 454 }); |
| 455 info.dependencySubscriptions.add(subscription); |
450 } | 456 } |
451 } | 457 } |
452 info.packageMapInfo = packageMapInfo; | 458 info.packageMapInfo = packageMapInfo; |
453 if (packageMapInfo.packageMap == null) { | 459 if (packageMapInfo.packageMap == null) { |
454 return null; | 460 return null; |
455 } | 461 } |
456 return new PackageMapUriResolver( | 462 return new PackageMapUriResolver( |
457 resourceProvider, packageMapInfo.packageMap); | 463 resourceProvider, packageMapInfo.packageMap); |
458 // TODO(paulberry): if any of the dependencies is outside of [folder], | 464 // TODO(paulberry): if any of the dependencies is outside of [folder], |
459 // we'll need to watch their parent folders as well. | 465 // we'll need to watch their parent folders as well. |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 return excludes(resource.path); | 833 return excludes(resource.path); |
828 } | 834 } |
829 | 835 |
830 /** | 836 /** |
831 * Returns `true` if [path] is the pubspec file of this context. | 837 * Returns `true` if [path] is the pubspec file of this context. |
832 */ | 838 */ |
833 bool isPubspec(String path) { | 839 bool isPubspec(String path) { |
834 return path == pubspecPath; | 840 return path == pubspecPath; |
835 } | 841 } |
836 } | 842 } |
OLD | NEW |