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

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

Issue 18650004: Make Assets know their ID. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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.transform; 5 library barback.transform;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'asset.dart'; 9 import 'asset.dart';
10 import 'asset_id.dart'; 10 import 'asset_id.dart';
11 import 'asset_node.dart'; 11 import 'asset_node.dart';
12 import 'errors.dart'; 12 import 'errors.dart';
13 import 'transform_node.dart'; 13 import 'transform_node.dart';
14 14
15 /// Creates a [Transform] by forwarding to the private constructor. 15 /// Creates a [Transform] by forwarding to the private constructor.
16 /// 16 ///
17 /// Lets [TransformNode] create [Transforms] without giving a [Transform] 17 /// Lets [TransformNode] create [Transforms] without giving a [Transform]
18 /// itself a public constructor, which would be visible to external users. 18 /// itself a public constructor, which would be visible to external users.
19 /// Unlike the [Transform] class, this function is not exported by barback.dart. 19 /// Unlike the [Transform] class, this function is not exported by barback.dart.
20 Transform createTransform(TransformNode node, Set<AssetNode> inputs, 20 Transform createTransform(TransformNode node, Set<AssetNode> inputs,
21 Map<AssetId, Asset> outputs) => 21 Set<Asset> outputs) =>
22 new Transform._(node, inputs, outputs); 22 new Transform._(node, inputs, outputs);
23 23
24 /// While a [Transformer] represents a *kind* of transformation, this defines 24 /// While a [Transformer] represents a *kind* of transformation, this defines
25 /// one specific usage of it on a set of files. 25 /// one specific usage of it on a set of files.
26 /// 26 ///
27 /// This ephemeral object exists only during an actual transform application to 27 /// This ephemeral object exists only during an actual transform application to
28 /// facilitate communication between the [Transformer] and the code hosting 28 /// facilitate communication between the [Transformer] and the code hosting
29 /// the transformation. It lets the [Transformer] access inputs and generate 29 /// the transformation. It lets the [Transformer] access inputs and generate
30 /// outputs. 30 /// outputs.
31 class Transform { 31 class Transform {
32 final TransformNode _node; 32 final TransformNode _node;
33 33
34 final Set<AssetNode> _inputs; 34 final Set<AssetNode> _inputs;
35 final Map<AssetId, Asset> _outputs; 35 final Set<Asset> _outputs;
36 36
37 /// Gets the ID of the primary input for this transformation. 37 /// Gets the ID of the primary input for this transformation.
38 /// 38 ///
39 /// While a transformation can use multiple input assets, one must be a 39 /// While a transformation can use multiple input assets, one must be a
40 /// special "primary" asset. This will be the "entrypoint" or "main" input 40 /// special "primary" asset. This will be the "entrypoint" or "main" input
41 /// file for a transformation. 41 /// file for a transformation.
42 /// 42 ///
43 /// For example, with a dart2js transform, the primary input would be the 43 /// For example, with a dart2js transform, the primary input would be the
44 /// entrypoint Dart file. All of the other Dart files that that imports 44 /// entrypoint Dart file. All of the other Dart files that that imports
45 /// would be secondary inputs. 45 /// would be secondary inputs.
(...skipping 18 matching lines...) Expand all
64 // is exited. We'll then catch this and report it through the proper 64 // is exited. We'll then catch this and report it through the proper
65 // results stream. 65 // results stream.
66 if (node == null) throw new MissingInputException(id); 66 if (node == null) throw new MissingInputException(id);
67 67
68 // Keep track of which assets this transform depends on. 68 // Keep track of which assets this transform depends on.
69 _inputs.add(node); 69 _inputs.add(node);
70 return node.asset; 70 return node.asset;
71 }); 71 });
72 } 72 }
73 73
74 /// Stores [output] as the output created by this transformation for asset 74 /// Stores [output] as the output created by this transformation.
75 /// [id]. A transformation can output as many assets as it wants. 75 ///
76 void addOutput(AssetId id, Asset output) { 76 /// A transformation can output as many assets as it wants.
77 _outputs[id] = output; 77 void addOutput(Asset output) {
nweiz 2013/07/03 20:08:25 This should throw an error if the transformer outp
Bob Nystrom 2013/07/03 22:32:11 Done.
78 _outputs.add(output);
78 } 79 }
79 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698