| 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:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 void addContext(Folder folder, UriResolver packageUriResolver); | 90 void addContext(Folder folder, UriResolver packageUriResolver); |
| 91 | 91 |
| 92 /** | 92 /** |
| 93 * Called when the set of files associated with a context have changed (or | 93 * Called when the set of files associated with a context have changed (or |
| 94 * some of those files have been modified). [changeSet] is the set of | 94 * some of those files have been modified). [changeSet] is the set of |
| 95 * changes that need to be applied to the context. | 95 * changes that need to be applied to the context. |
| 96 */ | 96 */ |
| 97 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet); | 97 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet); |
| 98 | 98 |
| 99 /** | 99 /** |
| 100 * We are about to start computing the package map. |
| 101 */ |
| 102 void beginComputePackageMap() { |
| 103 // Do nothing. |
| 104 } |
| 105 |
| 106 /** |
| 107 * We have finished computing the package map. |
| 108 */ |
| 109 void endComputePackageMap() { |
| 110 // Do nothing. |
| 111 } |
| 112 |
| 113 /** |
| 100 * Returns `true` if the given absolute [path] is in one of the current | 114 * Returns `true` if the given absolute [path] is in one of the current |
| 101 * root folders and is not excluded. | 115 * root folders and is not excluded. |
| 102 */ | 116 */ |
| 103 bool isInAnalysisRoot(String path) { | 117 bool isInAnalysisRoot(String path) { |
| 104 // check if excluded | 118 // check if excluded |
| 105 if (_isExcluded(path)) { | 119 if (_isExcluded(path)) { |
| 106 return false; | 120 return false; |
| 107 } | 121 } |
| 108 // check if in of the roots | 122 // check if in of the roots |
| 109 for (Folder root in _contexts.keys) { | 123 for (Folder root in _contexts.keys) { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 * Compute the appropriate package URI resolver for [folder], and store | 313 * Compute the appropriate package URI resolver for [folder], and store |
| 300 * dependency information in [info]. | 314 * dependency information in [info]. |
| 301 */ | 315 */ |
| 302 UriResolver _computePackageUriResolver(Folder folder, _ContextInfo info) { | 316 UriResolver _computePackageUriResolver(Folder folder, _ContextInfo info) { |
| 303 UriResolver packageUriResolver; | 317 UriResolver packageUriResolver; |
| 304 if (info.packageRoot != null) { | 318 if (info.packageRoot != null) { |
| 305 info.packageMapDependencies = new Set<String>(); | 319 info.packageMapDependencies = new Set<String>(); |
| 306 packageUriResolver = | 320 packageUriResolver = |
| 307 new PackageUriResolver([new JavaFile(info.packageRoot)]); | 321 new PackageUriResolver([new JavaFile(info.packageRoot)]); |
| 308 } else { | 322 } else { |
| 323 beginComputePackageMap(); |
| 309 PackageMapInfo packageMapInfo = | 324 PackageMapInfo packageMapInfo = |
| 310 _packageMapProvider.computePackageMap(folder); | 325 _packageMapProvider.computePackageMap(folder); |
| 326 endComputePackageMap(); |
| 311 info.packageMapDependencies = packageMapInfo.dependencies; | 327 info.packageMapDependencies = packageMapInfo.dependencies; |
| 312 packageUriResolver = | 328 packageUriResolver = |
| 313 new PackageMapUriResolver(resourceProvider, packageMapInfo.packageMap)
; | 329 new PackageMapUriResolver(resourceProvider, packageMapInfo.packageMap)
; |
| 314 // TODO(paulberry): if any of the dependencies is outside of [folder], | 330 // TODO(paulberry): if any of the dependencies is outside of [folder], |
| 315 // we'll need to watch their parent folders as well. | 331 // we'll need to watch their parent folders as well. |
| 316 } | 332 } |
| 317 return packageUriResolver; | 333 return packageUriResolver; |
| 318 } | 334 } |
| 319 | 335 |
| 320 /** | 336 /** |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 return excludes(resource.path); | 666 return excludes(resource.path); |
| 651 } | 667 } |
| 652 | 668 |
| 653 /** | 669 /** |
| 654 * Returns `true` if [path] is the pubspec file of this context. | 670 * Returns `true` if [path] is the pubspec file of this context. |
| 655 */ | 671 */ |
| 656 bool isPubspec(String path) { | 672 bool isPubspec(String path) { |
| 657 return path == pubspecPath; | 673 return path == pubspecPath; |
| 658 } | 674 } |
| 659 } | 675 } |
| OLD | NEW |