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

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

Issue 155213002: Add a bunch of toString methods to internal Barback classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 /// same id, causing collisions. This handles those collisions by forwarding the 21 /// same id, causing collisions. This handles those collisions by forwarding the
22 /// chronologically first asset. 22 /// chronologically first asset.
23 /// 23 ///
24 /// When the asset being forwarding changes, the old value of [output] will be 24 /// When the asset being forwarding changes, the old value of [output] will be
25 /// marked as removed and a new value will replace it. Users of this class can 25 /// marked as removed and a new value will replace it. Users of this class can
26 /// be notified of this using [onAsset]. 26 /// be notified of this using [onAsset].
27 class PhaseOutput { 27 class PhaseOutput {
28 /// The phase for which this is an output. 28 /// The phase for which this is an output.
29 final Phase _phase; 29 final Phase _phase;
30 30
31 /// A string describing the location of [this] in the transformer graph.
32 final String _location;
33
31 /// The asset node for this output. 34 /// The asset node for this output.
32 AssetNode get output => _outputForwarder.node; 35 AssetNode get output => _outputForwarder.node;
33 AssetForwarder _outputForwarder; 36 AssetForwarder _outputForwarder;
34 37
35 /// A stream that emits an [AssetNode] each time this output starts forwarding 38 /// A stream that emits an [AssetNode] each time this output starts forwarding
36 /// a new asset. 39 /// a new asset.
37 Stream<AssetNode> get onAsset => _onAssetController.stream; 40 Stream<AssetNode> get onAsset => _onAssetController.stream;
38 final _onAssetController = new StreamController<AssetNode>(); 41 final _onAssetController = new StreamController<AssetNode>();
39 42
40 /// The assets for this output. 43 /// The assets for this output.
41 /// 44 ///
42 /// If there's no collision, this will only have one element. Otherwise, it 45 /// If there's no collision, this will only have one element. Otherwise, it
43 /// will be ordered by which asset was added first. 46 /// will be ordered by which asset was added first.
44 final _assets = new Queue<AssetNode>(); 47 final _assets = new Queue<AssetNode>();
45 48
46 /// The [AssetCollisionException] for this output, or null if there is no 49 /// The [AssetCollisionException] for this output, or null if there is no
47 /// collision currently. 50 /// collision currently.
48 AssetCollisionException get collisionException { 51 AssetCollisionException get collisionException {
49 if (_assets.length == 1) return null; 52 if (_assets.length == 1) return null;
50 return new AssetCollisionException( 53 return new AssetCollisionException(
51 _assets.where((asset) => asset.transform != null) 54 _assets.where((asset) => asset.transform != null)
52 .map((asset) => asset.transform.info), 55 .map((asset) => asset.transform.info),
53 output.id); 56 output.id);
54 } 57 }
55 58
56 PhaseOutput(this._phase, AssetNode output) 59 PhaseOutput(this._phase, AssetNode output, this._location)
57 : _outputForwarder = new AssetForwarder(output) { 60 : _outputForwarder = new AssetForwarder(output) {
58 assert(!output.state.isRemoved); 61 assert(!output.state.isRemoved);
59 add(output); 62 add(output);
60 } 63 }
61 64
62 /// Adds an asset node as an output with this id. 65 /// Adds an asset node as an output with this id.
63 void add(AssetNode node) { 66 void add(AssetNode node) {
64 assert(node.id == output.id); 67 assert(node.id == output.id);
65 assert(!output.state.isRemoved); 68 assert(!output.state.isRemoved);
66 _assets.add(node); 69 _assets.add(node);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // If there's still a collision, report it. This lets the user know if 105 // If there's still a collision, report it. This lets the user know if
103 // they've successfully resolved the collision or not. 106 // they've successfully resolved the collision or not.
104 if (_assets.length > 1) { 107 if (_assets.length > 1) {
105 // Pump the event queue to ensure that the removal of the input triggers 108 // Pump the event queue to ensure that the removal of the input triggers
106 // a new build to which we can attach the error. 109 // a new build to which we can attach the error.
107 // TODO(nweiz): report this through the output asset. 110 // TODO(nweiz): report this through the output asset.
108 newFuture(() => _phase.cascade.reportError(collisionException)); 111 newFuture(() => _phase.cascade.reportError(collisionException));
109 } 112 }
110 }); 113 });
111 } 114 }
115
116 String toString() => "phase output in $_location for $output";
112 } 117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698