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

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

Issue 178223024: Refactor the Transform classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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) 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.transform; 5 library barback.transform;
6 6
7 import 'asset.dart'; 7 import 'asset.dart';
8 import 'asset_set.dart'; 8 import 'asset_set.dart';
9 import 'base_transform.dart'; 9 import 'base_transform.dart';
10 import 'transform_logger.dart';
11 import 'transform_node.dart'; 10 import 'transform_node.dart';
12 11
13 /// While a [Transformer] represents a *kind* of transformation, this defines 12 /// While a [Transformer] represents a *kind* of transformation, this defines
14 /// one specific usage of it on a set of files. 13 /// one specific usage of it on a set of files.
15 /// 14 ///
16 /// This ephemeral object exists only during an actual transform application to 15 /// This ephemeral object exists only during an actual transform application to
17 /// facilitate communication between the [Transformer] and the code hosting 16 /// facilitate communication between the [Transformer] and the code hosting
18 /// the transformation. It lets the [Transformer] access inputs and generate 17 /// the transformation. It lets the [Transformer] access inputs and generate
19 /// outputs. 18 /// outputs.
20 class Transform extends BaseTransform { 19 class Transform extends BaseTransform {
21 final AssetSet _outputs; 20 final _outputs = new AssetSet();
22 21
23 Transform(TransformNode node, this._outputs, LogFunction logFunction) 22 Transform._(TransformNode node)
24 : super(node, logFunction); 23 : super(node);
25 24
26 /// Stores [output] as the output created by this transformation. 25 /// Stores [output] as the output created by this transformation.
27 /// 26 ///
28 /// A transformation can output as many assets as it wants. 27 /// A transformation can output as many assets as it wants.
29 void addOutput(Asset output) { 28 void addOutput(Asset output) {
30 // TODO(rnystrom): This should immediately throw if an output with that ID 29 // TODO(rnystrom): This should immediately throw if an output with that ID
31 // has already been created by this transformer. 30 // has already been created by this transformer.
32 _outputs.add(output); 31 _outputs.add(output);
33 } 32 }
34 } 33 }
34
35 /// The controller for [Transform].
36 class TransformController extends BaseTransformController {
37 Transform get transform => super.transform;
38
39 /// The set of assets that the transformer has emitted.
40 AssetSet get outputs => transform._outputs;
41
42 TransformController(TransformNode node)
43 : super(new Transform._(node));
44 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698