| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.declaring_transform; | 5 library barback.declaring_transform; |
| 6 | 6 |
| 7 import 'asset_id.dart'; | 7 import 'asset_id.dart'; |
| 8 import 'base_transform.dart'; | 8 import 'base_transform.dart'; |
| 9 import 'transform_logger.dart'; | |
| 10 import 'transform_node.dart'; | 9 import 'transform_node.dart'; |
| 11 | 10 |
| 12 /// A transform for [DeclaringTransform]ers that allows them to declare the ids | 11 /// A transform for [DeclaringTransform]ers that allows them to declare the ids |
| 13 /// of the outputs they'll generate without generating the concrete bodies of | 12 /// of the outputs they'll generate without generating the concrete bodies of |
| 14 /// those outputs. | 13 /// those outputs. |
| 15 class DeclaringTransform extends BaseTransform { | 14 class DeclaringTransform extends BaseTransform { |
| 16 final Set<AssetId> _outputIds; | 15 final _outputIds = new Set<AssetId>(); |
| 17 | 16 |
| 18 DeclaringTransform(TransformNode node, this._outputIds, | 17 DeclaringTransform._(TransformNode node) |
| 19 LogFunction logFunction) | 18 : super(node); |
| 20 : super(node, logFunction); | |
| 21 | 19 |
| 22 /// Stores [id] as the id of an output that will be created by this | 20 /// Stores [id] as the id of an output that will be created by this |
| 23 /// transformation when it's run. | 21 /// transformation when it's run. |
| 24 /// | 22 /// |
| 25 /// A transformation can declare as many assets as it wants. If | 23 /// A transformation can declare as many assets as it wants. If |
| 26 /// [DeclaringTransformer.declareOutputs] declareds a given asset id for a | 24 /// [DeclaringTransformer.declareOutputs] declareds a given asset id for a |
| 27 /// given input, [Transformer.apply] should emit the corresponding asset as | 25 /// given input, [Transformer.apply] should emit the corresponding asset as |
| 28 /// well. | 26 /// well. |
| 29 void declareOutput(AssetId id) { | 27 void declareOutput(AssetId id) { |
| 30 // TODO(nweiz): This should immediately throw if an output with that ID | 28 // TODO(nweiz): This should immediately throw if an output with that ID |
| 31 // has already been declared by this transformer. | 29 // has already been declared by this transformer. |
| 32 _outputIds.add(id); | 30 _outputIds.add(id); |
| 33 } | 31 } |
| 34 } | 32 } |
| 33 |
| 34 /// The controller for [DeclaringTransform]. |
| 35 class DeclaringTransformController extends BaseTransformController { |
| 36 DeclaringTransform get transform => super.transform; |
| 37 |
| 38 /// The set of ids that the transformer declares it will emit for the given |
| 39 /// primary input. |
| 40 Set<AssetId> get outputIds => transform._outputIds; |
| 41 |
| 42 DeclaringTransformController(TransformNode node) |
| 43 : super(new DeclaringTransform._(node)); |
| 44 } |
| OLD | NEW |