| 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.phase; | 5 library barback.phase; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'asset_cascade.dart'; | 10 import 'asset_cascade.dart'; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 /// | 215 /// |
| 216 /// This may only be called on a phase with no phase following it. | 216 /// This may only be called on a phase with no phase following it. |
| 217 Phase addPhase(Iterable transformers) { | 217 Phase addPhase(Iterable transformers) { |
| 218 assert(_next == null); | 218 assert(_next == null); |
| 219 _next = new Phase(cascade, transformers); | 219 _next = new Phase(cascade, transformers); |
| 220 for (var output in _outputs.values.toList()) { | 220 for (var output in _outputs.values.toList()) { |
| 221 // Remove [output]'s listeners because now they should get the asset from | 221 // Remove [output]'s listeners because now they should get the asset from |
| 222 // [_next], rather than this phase. Any transforms consuming [output] will | 222 // [_next], rather than this phase. Any transforms consuming [output] will |
| 223 // be re-run and will consume the output from the new final phase. | 223 // be re-run and will consume the output from the new final phase. |
| 224 output.removeListeners(); | 224 output.removeListeners(); |
| 225 | |
| 226 // Removing [output]'s listeners will cause it to be removed from | |
| 227 // [_outputs], so we have to put it back. | |
| 228 _outputs[output.output.id] = output; | |
| 229 output.output.whenRemoved.then((_) => _outputs.remove(output.output.id)); | |
| 230 _next.addInput(output.output); | |
| 231 } | 225 } |
| 232 return _next; | 226 return _next; |
| 233 } | 227 } |
| 234 | 228 |
| 235 /// Mark this phase as removed. | 229 /// Mark this phase as removed. |
| 236 /// | 230 /// |
| 237 /// This will remove all the phase's outputs and all following phases. | 231 /// This will remove all the phase's outputs and all following phases. |
| 238 void remove() { | 232 void remove() { |
| 239 removeFollowing(); | 233 removeFollowing(); |
| 240 for (var input in _inputs.values.toList()) { | 234 for (var input in _inputs.values.toList()) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 } | 292 } |
| 299 }); | 293 }); |
| 300 } | 294 } |
| 301 | 295 |
| 302 /// Add [asset] as an output of this phase. | 296 /// Add [asset] as an output of this phase. |
| 303 void _addOutput(AssetNode asset) { | 297 void _addOutput(AssetNode asset) { |
| 304 if (_outputs.containsKey(asset.id)) { | 298 if (_outputs.containsKey(asset.id)) { |
| 305 _outputs[asset.id].add(asset); | 299 _outputs[asset.id].add(asset); |
| 306 } else { | 300 } else { |
| 307 _outputs[asset.id] = new PhaseOutput(this, asset); | 301 _outputs[asset.id] = new PhaseOutput(this, asset); |
| 308 _outputs[asset.id].output.whenRemoved.then((_) { | 302 _outputs[asset.id].onAsset.listen((output) { |
| 309 _outputs.remove(asset.id); | 303 if (_next != null) _next.addInput(output); |
| 310 }); | 304 }, onDone: () => _outputs.remove(asset.id)); |
| 311 if (_next != null) _next.addInput(_outputs[asset.id].output); | 305 if (_next != null) _next.addInput(_outputs[asset.id].output); |
| 312 } | 306 } |
| 313 } | 307 } |
| 314 } | 308 } |
| OLD | NEW |