| 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:core' hide Resource; | 9 import 'dart:core' hide Resource; |
| 10 | 10 |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 * Create a new empty context associated with [folder]. | 471 * Create a new empty context associated with [folder]. |
| 472 */ | 472 */ |
| 473 _ContextInfo _createContext( | 473 _ContextInfo _createContext( |
| 474 Folder folder, File pubspecFile, List<_ContextInfo> children) { | 474 Folder folder, File pubspecFile, List<_ContextInfo> children) { |
| 475 _ContextInfo info = new _ContextInfo( | 475 _ContextInfo info = new _ContextInfo( |
| 476 folder, pubspecFile, children, normalizedPackageRoots[folder.path]); | 476 folder, pubspecFile, children, normalizedPackageRoots[folder.path]); |
| 477 _contexts[folder] = info; | 477 _contexts[folder] = info; |
| 478 info.changeSubscription = folder.changes.listen((WatchEvent event) { | 478 info.changeSubscription = folder.changes.listen((WatchEvent event) { |
| 479 _handleWatchEvent(folder, info, event); | 479 _handleWatchEvent(folder, info, event); |
| 480 }); | 480 }); |
| 481 UriResolver packageUriResolver = _computePackageUriResolver(folder, info); | 481 try { |
| 482 info.context = addContext(folder, packageUriResolver); | 482 UriResolver packageUriResolver = _computePackageUriResolver(folder, info); |
| 483 info.context.name = folder.path; | 483 info.context = addContext(folder, packageUriResolver); |
| 484 info.context.name = folder.path; |
| 485 } catch (_) { |
| 486 info.changeSubscription.cancel(); |
| 487 rethrow; |
| 488 } |
| 484 return info; | 489 return info; |
| 485 } | 490 } |
| 486 | 491 |
| 487 /** | 492 /** |
| 488 * Potentially create a new context associated with the given [folder]. | 493 * Potentially create a new context associated with the given [folder]. |
| 489 * | 494 * |
| 490 * If there are subfolders with 'pubspec.yaml' files, separate contexts are | 495 * If there are subfolders with 'pubspec.yaml' files, separate contexts are |
| 491 * created for them and excluded from the context associated with the | 496 * created for them and excluded from the context associated with the |
| 492 * [folder]. | 497 * [folder]. |
| 493 * | 498 * |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 return excludes(resource.path); | 839 return excludes(resource.path); |
| 835 } | 840 } |
| 836 | 841 |
| 837 /** | 842 /** |
| 838 * Returns `true` if [path] is the pubspec file of this context. | 843 * Returns `true` if [path] is the pubspec file of this context. |
| 839 */ | 844 */ |
| 840 bool isPubspec(String path) { | 845 bool isPubspec(String path) { |
| 841 return path == pubspecPath; | 846 return path == pubspecPath; |
| 842 } | 847 } |
| 843 } | 848 } |
| OLD | NEW |