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_node.dart'; | 9 import 'transform_node.dart'; |
10 | 10 |
11 /// 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 |
12 /// 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 |
13 /// those outputs. | 13 /// those outputs. |
14 class DeclaringTransform extends BaseTransform { | 14 class DeclaringTransform extends BaseTransform { |
15 final _outputIds = new Set<AssetId>(); | 15 final _outputIds = new Set<AssetId>(); |
16 | 16 |
| 17 final AssetId primaryId; |
| 18 |
17 DeclaringTransform._(TransformNode node) | 19 DeclaringTransform._(TransformNode node) |
18 : super(node); | 20 : primaryId = node.primary.id, |
| 21 super(node); |
19 | 22 |
20 /// Stores [id] as the id of an output that will be created by this | 23 /// Stores [id] as the id of an output that will be created by this |
21 /// transformation when it's run. | 24 /// transformation when it's run. |
22 /// | 25 /// |
23 /// A transformation can declare as many assets as it wants. If | 26 /// A transformation can declare as many assets as it wants. If |
24 /// [DeclaringTransformer.declareOutputs] declareds a given asset id for a | 27 /// [DeclaringTransformer.declareOutputs] declareds a given asset id for a |
25 /// given input, [Transformer.apply] should emit the corresponding asset as | 28 /// given input, [Transformer.apply] should emit the corresponding asset as |
26 /// well. | 29 /// well. |
27 void declareOutput(AssetId id) { | 30 void declareOutput(AssetId id) { |
28 // TODO(nweiz): This should immediately throw if an output with that ID | 31 // TODO(nweiz): This should immediately throw if an output with that ID |
29 // has already been declared by this transformer. | 32 // has already been declared by this transformer. |
30 _outputIds.add(id); | 33 _outputIds.add(id); |
31 } | 34 } |
32 } | 35 } |
33 | 36 |
34 /// The controller for [DeclaringTransform]. | 37 /// The controller for [DeclaringTransform]. |
35 class DeclaringTransformController extends BaseTransformController { | 38 class DeclaringTransformController extends BaseTransformController { |
36 DeclaringTransform get transform => super.transform; | 39 DeclaringTransform get transform => super.transform; |
37 | 40 |
38 /// The set of ids that the transformer declares it will emit for the given | 41 /// The set of ids that the transformer declares it will emit for the given |
39 /// primary input. | 42 /// primary input. |
40 Set<AssetId> get outputIds => transform._outputIds; | 43 Set<AssetId> get outputIds => transform._outputIds; |
41 | 44 |
42 DeclaringTransformController(TransformNode node) | 45 DeclaringTransformController(TransformNode node) |
43 : super(new DeclaringTransform._(node)); | 46 : super(new DeclaringTransform._(node)); |
44 } | 47 } |
OLD | NEW |