| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 input.updateTransformers(_transformers); | 132 input.updateTransformers(_transformers); |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 | 135 |
| 136 /// Add a new phase after this one with [transformers]. | 136 /// Add a new phase after this one with [transformers]. |
| 137 /// | 137 /// |
| 138 /// This may only be called on a phase with no phase following it. | 138 /// This may only be called on a phase with no phase following it. |
| 139 Phase addPhase(Iterable<Transformer> transformers) { | 139 Phase addPhase(Iterable<Transformer> transformers) { |
| 140 assert(_next == null); | 140 assert(_next == null); |
| 141 _next = new Phase(cascade, transformers); | 141 _next = new Phase(cascade, transformers); |
| 142 for (var outputs in _outputs.values) { | 142 for (var output in _outputs.values.toList()) { |
| 143 _next.addInput(outputs.output); | 143 // Remove [output]'s listeners because now they should get the asset from |
| 144 // [_next], rather than this phase. Any transforms consuming [output] will |
| 145 // be re-run and will consume the output from the new final phase. |
| 146 output.removeListeners(); |
| 147 |
| 148 // Removing [output]'s listeners will cause it to be removed from |
| 149 // [_outputs], so we have to put it back. |
| 150 _outputs[output.output.id] = output; |
| 151 _next.addInput(output.output); |
| 144 } | 152 } |
| 145 return _next; | 153 return _next; |
| 146 } | 154 } |
| 147 | 155 |
| 148 /// Processes this phase. | 156 /// Processes this phase. |
| 149 /// | 157 /// |
| 150 /// Returns a future that completes when processing is done. If there is | 158 /// Returns a future that completes when processing is done. If there is |
| 151 /// nothing to process, returns `null`. | 159 /// nothing to process, returns `null`. |
| 152 Future process() { | 160 Future process() { |
| 153 if (!_inputs.values.any((input) => input.isDirty)) return null; | 161 if (!_inputs.values.any((input) => input.isDirty)) return null; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 175 for (var id in outputIds) { | 183 for (var id in outputIds) { |
| 176 // It's possible the output was removed before other transforms in this | 184 // It's possible the output was removed before other transforms in this |
| 177 // phase finished. | 185 // phase finished. |
| 178 if (!_outputs.containsKey(id)) continue; | 186 if (!_outputs.containsKey(id)) continue; |
| 179 var exception = _outputs[id].collisionException; | 187 var exception = _outputs[id].collisionException; |
| 180 if (exception != null) cascade.reportError(exception); | 188 if (exception != null) cascade.reportError(exception); |
| 181 } | 189 } |
| 182 }); | 190 }); |
| 183 } | 191 } |
| 184 } | 192 } |
| OLD | NEW |