| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 barback.package_graph; | 5 library barback.package_graph; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:stack_trace/stack_trace.dart'; | 9 import 'package:stack_trace/stack_trace.dart'; |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 _cascadeResults.values.map((result) => result.errors)))); | 78 _cascadeResults.values.map((result) => result.errors)))); |
| 79 }, onError: _resultsController.addError); | 79 }, onError: _resultsController.addError); |
| 80 } | 80 } |
| 81 | 81 |
| 82 _errors = mergeStreams(_cascades.values.map((cascade) => cascade.errors)); | 82 _errors = mergeStreams(_cascades.values.map((cascade) => cascade.errors)); |
| 83 } | 83 } |
| 84 | 84 |
| 85 /// Gets the asset node identified by [id]. | 85 /// Gets the asset node identified by [id]. |
| 86 /// | 86 /// |
| 87 /// If [id] is for a generated or transformed asset, this will wait until it | 87 /// If [id] is for a generated or transformed asset, this will wait until it |
| 88 /// has been created and return it. If the asset cannot be found, returns | 88 /// has been created and return it. This means that the returned asset will |
| 89 /// null. | 89 /// always be [AssetState.AVAILABLE]. |
| 90 /// |
| 91 /// If the asset cannot be found, returns null. |
| 90 Future<AssetNode> getAssetNode(AssetId id) { | 92 Future<AssetNode> getAssetNode(AssetId id) { |
| 91 var cascade = _cascades[id.package]; | 93 var cascade = _cascades[id.package]; |
| 92 if (cascade != null) return cascade.getAssetNode(id); | 94 if (cascade != null) return cascade.getAssetNode(id); |
| 93 return new Future.value(null); | 95 return new Future.value(null); |
| 94 } | 96 } |
| 95 | 97 |
| 96 /// Adds [sources] to the graph's known set of source assets. | 98 /// Adds [sources] to the graph's known set of source assets. |
| 97 /// | 99 /// |
| 98 /// Begins applying any transforms that can consume any of the sources. If a | 100 /// Begins applying any transforms that can consume any of the sources. If a |
| 99 /// given source is already known, it is considered modified and all | 101 /// given source is already known, it is considered modified and all |
| (...skipping 10 matching lines...) Expand all Loading... |
| 110 /// Removes [removed] from the graph's known set of source assets. | 112 /// Removes [removed] from the graph's known set of source assets. |
| 111 void removeSources(Iterable<AssetId> sources) { | 113 void removeSources(Iterable<AssetId> sources) { |
| 112 groupBy(sources, (id) => id.package).forEach((package, ids) { | 114 groupBy(sources, (id) => id.package).forEach((package, ids) { |
| 113 var cascade = _cascades[package]; | 115 var cascade = _cascades[package]; |
| 114 if (cascade == null) throw new ArgumentError("Unknown package $package."); | 116 if (cascade == null) throw new ArgumentError("Unknown package $package."); |
| 115 _cascadeResults[package] = null; | 117 _cascadeResults[package] = null; |
| 116 cascade.removeSources(ids); | 118 cascade.removeSources(ids); |
| 117 }); | 119 }); |
| 118 } | 120 } |
| 119 } | 121 } |
| OLD | NEW |