| 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.transform_node; | 5 library barback.transform_node; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:source_maps/span.dart'; | 9 import 'package:source_maps/span.dart'; |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class TransformNode { | 26 class TransformNode { |
| 27 /// The [Phase] that this transform runs in. | 27 /// The [Phase] that this transform runs in. |
| 28 final Phase phase; | 28 final Phase phase; |
| 29 | 29 |
| 30 /// The [Transformer] to apply to this node's inputs. | 30 /// The [Transformer] to apply to this node's inputs. |
| 31 final Transformer transformer; | 31 final Transformer transformer; |
| 32 | 32 |
| 33 /// The node for the primary asset this transform depends on. | 33 /// The node for the primary asset this transform depends on. |
| 34 final AssetNode primary; | 34 final AssetNode primary; |
| 35 | 35 |
| 36 /// A string describing the location of [this] in the transformer graph. |
| 37 final String _location; |
| 38 |
| 36 /// The subscription to [primary]'s [AssetNode.onStateChange] stream. | 39 /// The subscription to [primary]'s [AssetNode.onStateChange] stream. |
| 37 StreamSubscription _primarySubscription; | 40 StreamSubscription _primarySubscription; |
| 38 | 41 |
| 39 /// True if an input has been modified since the last time this transform | 42 /// True if an input has been modified since the last time this transform |
| 40 /// began running. | 43 /// began running. |
| 41 bool get isDirty => _isDirty; | 44 bool get isDirty => _isDirty; |
| 42 var _isDirty = true; | 45 var _isDirty = true; |
| 43 | 46 |
| 44 /// The subscriptions to each input's [AssetNode.onStateChange] stream. | 47 /// The subscriptions to each input's [AssetNode.onStateChange] stream. |
| 45 var _inputSubscriptions = new Map<AssetId, StreamSubscription>(); | 48 var _inputSubscriptions = new Map<AssetId, StreamSubscription>(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 57 final _onDirtyController = new StreamController.broadcast(sync: true); | 60 final _onDirtyController = new StreamController.broadcast(sync: true); |
| 58 | 61 |
| 59 /// A stream that emits an event whenever this transform logs an entry. | 62 /// A stream that emits an event whenever this transform logs an entry. |
| 60 /// | 63 /// |
| 61 /// This is synchronous because error logs can cause the transform to fail, so | 64 /// This is synchronous because error logs can cause the transform to fail, so |
| 62 /// we need to ensure that their processing isn't delayed until after the | 65 /// we need to ensure that their processing isn't delayed until after the |
| 63 /// transform or build has finished. | 66 /// transform or build has finished. |
| 64 Stream<LogEntry> get onLog => _onLogController.stream; | 67 Stream<LogEntry> get onLog => _onLogController.stream; |
| 65 final _onLogController = new StreamController<LogEntry>.broadcast(sync: true); | 68 final _onLogController = new StreamController<LogEntry>.broadcast(sync: true); |
| 66 | 69 |
| 67 TransformNode(this.phase, this.transformer, this.primary) { | 70 TransformNode(this.phase, this.transformer, this.primary, this._location) { |
| 68 _primarySubscription = primary.onStateChange.listen((state) { | 71 _primarySubscription = primary.onStateChange.listen((state) { |
| 69 if (state.isRemoved) { | 72 if (state.isRemoved) { |
| 70 remove(); | 73 remove(); |
| 71 } else { | 74 } else { |
| 72 _dirty(); | 75 _dirty(); |
| 73 } | 76 } |
| 74 }); | 77 }); |
| 75 } | 78 } |
| 76 | 79 |
| 77 /// The [TransformInfo] describing this node. | 80 /// The [TransformInfo] describing this node. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 215 |
| 213 return brandNewOutputs; | 216 return brandNewOutputs; |
| 214 } | 217 } |
| 215 | 218 |
| 216 void _log(AssetId asset, LogLevel level, String message, Span span) { | 219 void _log(AssetId asset, LogLevel level, String message, Span span) { |
| 217 // If the log isn't already associated with an asset, use the primary. | 220 // If the log isn't already associated with an asset, use the primary. |
| 218 if (asset == null) asset = primary.id; | 221 if (asset == null) asset = primary.id; |
| 219 var entry = new LogEntry(info, asset, level, message, span); | 222 var entry = new LogEntry(info, asset, level, message, span); |
| 220 _onLogController.add(entry); | 223 _onLogController.add(entry); |
| 221 } | 224 } |
| 225 |
| 226 String toString() => |
| 227 "transform node in $_location for $transformer on $primary"; |
| 222 } | 228 } |
| OLD | NEW |