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

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

Issue 23171020: Enable cross-package transforms to see new transformers in other packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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_output; 5 library barback.phase_output;
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 10 matching lines...) Expand all
21 /// Normally there's only a single [AssetNode] for a phase's output, but it's 21 /// Normally there's only a single [AssetNode] for a phase's output, but it's
22 /// possible that multiple transformers in the same phase emit assets with the 22 /// possible that multiple transformers in the same phase emit assets with the
23 /// same id, causing collisions. This handles those collisions by forwarding the 23 /// same id, causing collisions. This handles those collisions by forwarding the
24 /// chronologically first asset. 24 /// chronologically first asset.
25 class PhaseOutput { 25 class PhaseOutput {
26 /// The phase for which this is an output. 26 /// The phase for which this is an output.
27 final Phase _phase; 27 final Phase _phase;
28 28
29 /// The asset node for this output. 29 /// The asset node for this output.
30 AssetNode get output => _outputController.node; 30 AssetNode get output => _outputController.node;
31 final AssetNodeController _outputController; 31 AssetNodeController _outputController;
32 32
33 /// The assets for this output. 33 /// The assets for this output.
34 /// 34 ///
35 /// If there's no collision, this will only have one element. Otherwise, it 35 /// If there's no collision, this will only have one element. Otherwise, it
36 /// will be ordered by which asset was added first. 36 /// will be ordered by which asset was added first.
37 final _assets = new Queue<AssetNode>(); 37 final _assets = new Queue<AssetNode>();
38 38
39 /// The [AssetCollisionException] for this output, or null if there is no 39 /// The [AssetCollisionException] for this output, or null if there is no
40 /// collision currently. 40 /// collision currently.
41 AssetCollisionException get collisionException { 41 AssetCollisionException get collisionException {
(...skipping 10 matching lines...) Expand all
52 add(output); 52 add(output);
53 } 53 }
54 54
55 /// Adds an asset node as an output with this id. 55 /// Adds an asset node as an output with this id.
56 void add(AssetNode node) { 56 void add(AssetNode node) {
57 assert(node.id == output.id); 57 assert(node.id == output.id);
58 _assets.add(node); 58 _assets.add(node);
59 _watchAsset(node); 59 _watchAsset(node);
60 } 60 }
61 61
62 /// Removes all existing listeners on [output] without actually closing
63 /// [this].
64 ///
65 /// This marks [output] as removed, but immediately replaces it with a new
66 /// [AssetNode] in the same state as the old output.
Bob Nystrom 2013/08/22 19:34:19 A bit of motivation here would help.
67 void removeListeners() {
68 _outputController.setRemoved();
69 _outputController = new AssetNodeController.from(_assets.first);
70 }
71
62 /// Watches [node] for state changes and adjusts [_assets] and [output] 72 /// Watches [node] for state changes and adjusts [_assets] and [output]
63 /// appropriately when they occur. 73 /// appropriately when they occur.
64 void _watchAsset(AssetNode node) { 74 void _watchAsset(AssetNode node) {
65 node.onStateChange.listen((state) { 75 node.onStateChange.listen((state) {
66 if (state.isRemoved) { 76 if (state.isRemoved) {
67 _removeAsset(node); 77 _removeAsset(node);
68 return; 78 return;
69 } 79 }
70 if (_assets.first != node) return; 80 if (_assets.first != node) return;
71 81
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // If there's still a collision, report it. This lets the user know 118 // If there's still a collision, report it. This lets the user know
109 // if they've successfully resolved the collision or not. 119 // if they've successfully resolved the collision or not.
110 if (_assets.length > 1) { 120 if (_assets.length > 1) {
111 // Pump the event queue to ensure that the removal of the input triggers 121 // Pump the event queue to ensure that the removal of the input triggers
112 // a new build to which we can attach the error. 122 // a new build to which we can attach the error.
113 // TODO(nweiz): report this through the output asset. 123 // TODO(nweiz): report this through the output asset.
114 newFuture(() => _phase.cascade.reportError(collisionException)); 124 newFuture(() => _phase.cascade.reportError(collisionException));
115 } 125 }
116 } 126 }
117 } 127 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698