| 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 import 'dart:convert'; | 9 import 'dart:convert'; |
| 10 import 'dart:core' hide Resource; | 10 import 'dart:core' hide Resource; |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 | 708 |
| 709 /** | 709 /** |
| 710 * Compute the appropriate package URI resolver for [folder], and store | 710 * Compute the appropriate package URI resolver for [folder], and store |
| 711 * dependency information in [info]. Return `null` if no package map can | 711 * dependency information in [info]. Return `null` if no package map can |
| 712 * be computed. | 712 * be computed. |
| 713 */ | 713 */ |
| 714 UriResolver _computePackageUriResolver(Folder folder, ContextInfo info) { | 714 UriResolver _computePackageUriResolver(Folder folder, ContextInfo info) { |
| 715 _cancelDependencySubscriptions(info); | 715 _cancelDependencySubscriptions(info); |
| 716 if (info.packageRoot != null) { | 716 if (info.packageRoot != null) { |
| 717 info.packageMapInfo = null; | 717 info.packageMapInfo = null; |
| 718 // TODO(paulberry): We shouldn't be using JavaFile here because it |
| 719 // makes the code untestable (see dartbug.com/23909). |
| 718 JavaFile packagesDir = new JavaFile(info.packageRoot); | 720 JavaFile packagesDir = new JavaFile(info.packageRoot); |
| 719 Map<String, List<Folder>> packageMap = new Map<String, List<Folder>>(); | 721 Map<String, List<Folder>> packageMap = new Map<String, List<Folder>>(); |
| 720 if (packagesDir.isDirectory()) { | 722 if (packagesDir.isDirectory()) { |
| 721 for (JavaFile file in packagesDir.listFiles()) { | 723 for (JavaFile file in packagesDir.listFiles()) { |
| 722 // Ensure symlinks in packages directory are canonicalized | 724 // Ensure symlinks in packages directory are canonicalized |
| 723 // to prevent 'type X cannot be assigned to type X' warnings | 725 // to prevent 'type X cannot be assigned to type X' warnings |
| 724 String path; | 726 String path; |
| 725 try { | 727 try { |
| 726 path = file.getCanonicalPath(); | 728 path = file.getCanonicalPath(); |
| 727 } catch (e, s) { | 729 } catch (e, s) { |
| 728 // Ignore packages that do not exist | 730 // Ignore packages that do not exist |
| 729 _instrumentationService.logException(e, s); | 731 _instrumentationService.logException(e, s); |
| 730 continue; | 732 continue; |
| 731 } | 733 } |
| 732 Resource res = resourceProvider.getResource(path); | 734 Resource res = resourceProvider.getResource(path); |
| 733 if (res is Folder) { | 735 if (res is Folder) { |
| 734 packageMap[file.getName()] = <Folder>[res]; | 736 packageMap[file.getName()] = <Folder>[res]; |
| 735 } | 737 } |
| 736 } | 738 } |
| 737 return new PackageMapUriResolver(resourceProvider, packageMap); | 739 return new PackageMapUriResolver(resourceProvider, packageMap); |
| 738 } | 740 } |
| 739 //TODO(danrubel) remove this if it will never be called | 741 // The package root does not exist (or is not a folder). Since |
| 740 return new PackageUriResolver([packagesDir]); | 742 // [setRoots] ignores any package roots that don't exist (or aren't |
| 743 // folders), the only way we should be able to get here is due to a race |
| 744 // condition. In any case, the package root folder is gone, so we can't |
| 745 // resolve packages. |
| 746 return null; |
| 741 } else { | 747 } else { |
| 742 callbacks.beginComputePackageMap(); | 748 callbacks.beginComputePackageMap(); |
| 743 if (packageResolverProvider != null) { | 749 if (packageResolverProvider != null) { |
| 744 UriResolver resolver = packageResolverProvider(folder); | 750 UriResolver resolver = packageResolverProvider(folder); |
| 745 if (resolver != null) { | 751 if (resolver != null) { |
| 746 return resolver; | 752 return resolver; |
| 747 } | 753 } |
| 748 } | 754 } |
| 749 OptimizingPubPackageMapInfo packageMapInfo; | 755 OptimizingPubPackageMapInfo packageMapInfo; |
| 750 ServerPerformanceStatistics.pub.makeCurrentWhile(() { | 756 ServerPerformanceStatistics.pub.makeCurrentWhile(() { |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 */ | 1215 */ |
| 1210 final List<AnalysisContext> removed; | 1216 final List<AnalysisContext> removed; |
| 1211 | 1217 |
| 1212 /** | 1218 /** |
| 1213 * Initialize a newly created event to indicate which contexts have changed. | 1219 * Initialize a newly created event to indicate which contexts have changed. |
| 1214 */ | 1220 */ |
| 1215 ContextsChangedEvent({this.added: AnalysisContext.EMPTY_LIST, | 1221 ContextsChangedEvent({this.added: AnalysisContext.EMPTY_LIST, |
| 1216 this.changed: AnalysisContext.EMPTY_LIST, | 1222 this.changed: AnalysisContext.EMPTY_LIST, |
| 1217 this.removed: AnalysisContext.EMPTY_LIST}); | 1223 this.removed: AnalysisContext.EMPTY_LIST}); |
| 1218 } | 1224 } |
| OLD | NEW |