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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 if (child.shortName == PACKAGES_NAME) { | 304 if (child.shortName == PACKAGES_NAME) { |
305 continue; | 305 continue; |
306 } | 306 } |
307 _addSourceFiles(changeSet, child, info); | 307 _addSourceFiles(changeSet, child, info); |
308 } | 308 } |
309 } | 309 } |
310 } | 310 } |
311 | 311 |
312 /** | 312 /** |
313 * Compute the appropriate package URI resolver for [folder], and store | 313 * Compute the appropriate package URI resolver for [folder], and store |
314 * dependency information in [info]. | 314 * dependency information in [info]. Return `null` if no package map can |
| 315 * be computed. |
315 */ | 316 */ |
316 UriResolver _computePackageUriResolver(Folder folder, _ContextInfo info) { | 317 UriResolver _computePackageUriResolver(Folder folder, _ContextInfo info) { |
317 UriResolver packageUriResolver; | |
318 if (info.packageRoot != null) { | 318 if (info.packageRoot != null) { |
319 info.packageMapDependencies = new Set<String>(); | 319 info.packageMapDependencies = new Set<String>(); |
320 packageUriResolver = | 320 return new PackageUriResolver([new JavaFile(info.packageRoot)]); |
321 new PackageUriResolver([new JavaFile(info.packageRoot)]); | |
322 } else { | 321 } else { |
323 beginComputePackageMap(); | 322 beginComputePackageMap(); |
324 PackageMapInfo packageMapInfo = | 323 PackageMapInfo packageMapInfo = |
325 _packageMapProvider.computePackageMap(folder); | 324 _packageMapProvider.computePackageMap(folder); |
326 endComputePackageMap(); | 325 endComputePackageMap(); |
327 info.packageMapDependencies = packageMapInfo.dependencies; | 326 info.packageMapDependencies = packageMapInfo.dependencies; |
328 packageUriResolver = | 327 if (packageMapInfo.packageMap == null) { |
329 new PackageMapUriResolver(resourceProvider, packageMapInfo.packageMap)
; | 328 return null; |
| 329 } |
| 330 return new PackageMapUriResolver( |
| 331 resourceProvider, |
| 332 packageMapInfo.packageMap); |
330 // TODO(paulberry): if any of the dependencies is outside of [folder], | 333 // TODO(paulberry): if any of the dependencies is outside of [folder], |
331 // we'll need to watch their parent folders as well. | 334 // we'll need to watch their parent folders as well. |
332 } | 335 } |
333 return packageUriResolver; | |
334 } | 336 } |
335 | 337 |
336 /** | 338 /** |
337 * Create a new empty context associated with [folder]. | 339 * Create a new empty context associated with [folder]. |
338 */ | 340 */ |
339 _ContextInfo _createContext(Folder folder, List<_ContextInfo> children) { | 341 _ContextInfo _createContext(Folder folder, List<_ContextInfo> children) { |
340 _ContextInfo info = | 342 _ContextInfo info = |
341 new _ContextInfo(folder, children, normalizedPackageRoots[folder.path]); | 343 new _ContextInfo(folder, children, normalizedPackageRoots[folder.path]); |
342 _contexts[folder] = info; | 344 _contexts[folder] = info; |
343 info.changeSubscription = folder.changes.listen((WatchEvent event) { | 345 info.changeSubscription = folder.changes.listen((WatchEvent event) { |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 return excludes(resource.path); | 668 return excludes(resource.path); |
667 } | 669 } |
668 | 670 |
669 /** | 671 /** |
670 * Returns `true` if [path] is the pubspec file of this context. | 672 * Returns `true` if [path] is the pubspec file of this context. |
671 */ | 673 */ |
672 bool isPubspec(String path) { | 674 bool isPubspec(String path) { |
673 return path == pubspecPath; | 675 return path == pubspecPath; |
674 } | 676 } |
675 } | 677 } |
OLD | NEW |