| 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.asset_cascade; | 5 library barback.asset_cascade; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'asset.dart'; | 10 import 'asset.dart'; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 179 |
| 180 for (var i = 0; i < transformers.length; i++) { | 180 for (var i = 0; i < transformers.length; i++) { |
| 181 if (_phases.length > i) { | 181 if (_phases.length > i) { |
| 182 _phases[i].updateTransformers(transformers[i]); | 182 _phases[i].updateTransformers(transformers[i]); |
| 183 continue; | 183 continue; |
| 184 } | 184 } |
| 185 | 185 |
| 186 _addPhase(_phases.last.addPhase(transformers[i])); | 186 _addPhase(_phases.last.addPhase(transformers[i])); |
| 187 } | 187 } |
| 188 | 188 |
| 189 if (transformers.length < _phases.length) { | 189 if (transformers.length == 0) { |
| 190 for (var i = transformers.length; i < _phases.length; i++) { | 190 _phases.last.updateTransformers([]); |
| 191 // TODO(nweiz): actually remove phases rather than emptying them of | 191 } else if (transformers.length < _phases.length) { |
| 192 // transformers. | 192 _phases[transformers.length - 1].removeFollowing(); |
| 193 _phases[i].updateTransformers([]); | 193 _phases.removeRange(transformers.length, _phases.length); |
| 194 } | |
| 195 } | 194 } |
| 196 } | 195 } |
| 197 | 196 |
| 198 void reportError(BarbackException error) { | 197 void reportError(BarbackException error) { |
| 199 _accumulatedErrors.add(error); | 198 _accumulatedErrors.add(error); |
| 200 _errorsController.add(error); | 199 _errorsController.add(error); |
| 201 } | 200 } |
| 202 | 201 |
| 203 /// Add [phase] to the end of [_phases] and watch its [onDirty] stream. | 202 /// Add [phase] to the end of [_phases] and watch its [onDirty] stream. |
| 204 void _addPhase(Phase phase) { | 203 void _addPhase(Phase phase) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 259 |
| 261 // Otherwise, everything is done. | 260 // Otherwise, everything is done. |
| 262 return; | 261 return; |
| 263 } | 262 } |
| 264 | 263 |
| 265 // Process that phase and then loop onto the next. | 264 // Process that phase and then loop onto the next. |
| 266 return future.then((_) => _process()); | 265 return future.then((_) => _process()); |
| 267 }); | 266 }); |
| 268 } | 267 } |
| 269 } | 268 } |
| OLD | NEW |