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