Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: pkg/barback/lib/src/phase.dart

Issue 23803006: Fix a subtle bug in barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 _next = new Phase(cascade, transformers); 141 _next = new Phase(cascade, transformers);
142 for (var output in _outputs.values.toList()) { 142 for (var output in _outputs.values.toList()) {
143 // Remove [output]'s listeners because now they should get the asset from 143 // Remove [output]'s listeners because now they should get the asset from
144 // [_next], rather than this phase. Any transforms consuming [output] will 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. 145 // be re-run and will consume the output from the new final phase.
146 output.removeListeners(); 146 output.removeListeners();
147 147
148 // Removing [output]'s listeners will cause it to be removed from 148 // Removing [output]'s listeners will cause it to be removed from
149 // [_outputs], so we have to put it back. 149 // [_outputs], so we have to put it back.
150 _outputs[output.output.id] = output; 150 _outputs[output.output.id] = output;
151 _outputs[output.output.id].output.whenRemoved.then((_) {
Bob Nystrom 2013/09/05 00:09:55 Instead of "_outputs[output.output.id]" here, can
nweiz 2013/09/05 00:13:09 Done.
152 _outputs.remove(output.output.id);
153 });
151 _next.addInput(output.output); 154 _next.addInput(output.output);
152 } 155 }
153 return _next; 156 return _next;
154 } 157 }
155 158
156 /// Mark this phase as removed. 159 /// Mark this phase as removed.
157 /// 160 ///
158 /// This will remove all the phase's outputs and all following phases. 161 /// This will remove all the phase's outputs and all following phases.
159 void remove() { 162 void remove() {
160 removeFollowing(); 163 removeFollowing();
(...skipping 20 matching lines...) Expand all
181 var outputIds = new Set<AssetId>(); 184 var outputIds = new Set<AssetId>();
182 return Future.wait(_inputs.values.map((input) { 185 return Future.wait(_inputs.values.map((input) {
183 if (!input.isDirty) return new Future.value(new Set()); 186 if (!input.isDirty) return new Future.value(new Set());
184 return input.process().then((outputs) { 187 return input.process().then((outputs) {
185 for (var asset in outputs) { 188 for (var asset in outputs) {
186 outputIds.add(asset.id); 189 outputIds.add(asset.id);
187 if (_outputs.containsKey(asset.id)) { 190 if (_outputs.containsKey(asset.id)) {
188 _outputs[asset.id].add(asset); 191 _outputs[asset.id].add(asset);
189 } else { 192 } else {
190 _outputs[asset.id] = new PhaseOutput(this, asset); 193 _outputs[asset.id] = new PhaseOutput(this, asset);
191 _outputs[asset.id].output.whenRemoved 194 _outputs[asset.id].output.whenRemoved.then((_) {
192 .then((_) => _outputs.remove(asset.id)); 195 _outputs.remove(asset.id);
196 });
193 if (_next != null) _next.addInput(_outputs[asset.id].output); 197 if (_next != null) _next.addInput(_outputs[asset.id].output);
194 } 198 }
195 } 199 }
196 }); 200 });
197 })).then((_) { 201 })).then((_) {
198 // Report collisions in a deterministic order. 202 // Report collisions in a deterministic order.
199 outputIds = outputIds.toList(); 203 outputIds = outputIds.toList();
200 outputIds.sort((a, b) => a.compareTo(b)); 204 outputIds.sort((a, b) => a.compareTo(b));
201 for (var id in outputIds) { 205 for (var id in outputIds) {
202 // It's possible the output was removed before other transforms in this 206 // It's possible the output was removed before other transforms in this
203 // phase finished. 207 // phase finished.
204 if (!_outputs.containsKey(id)) continue; 208 if (!_outputs.containsKey(id)) continue;
205 var exception = _outputs[id].collisionException; 209 var exception = _outputs[id].collisionException;
206 if (exception != null) cascade.reportError(exception); 210 if (exception != null) cascade.reportError(exception);
207 } 211 }
208 }); 212 });
209 } 213 }
210 } 214 }
OLDNEW
« no previous file with comments | « no previous file | pkg/barback/lib/src/phase_output.dart » ('j') | pkg/barback/test/package_graph/add_remove_transform_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698