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

Side by Side Diff: pkg/barback/lib/src/transformer.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.transformer; 5 library barback.transformer;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'asset_id.dart'; 10 import 'asset.dart';
11 import 'transform.dart'; 11 import 'transform.dart';
12 12
13 /// A [Transformer] represents a processor that takes in one or more input 13 /// A [Transformer] represents a processor that takes in one or more input
14 /// assets and uses them to generate one or more output assets. 14 /// assets and uses them to generate one or more output assets.
15 /// 15 ///
16 /// Dart2js, a SASS->CSS processor, a CSS spriter, and a tool to concatenate 16 /// Dart2js, a SASS->CSS processor, a CSS spriter, and a tool to concatenate
17 /// files are all examples of transformers. To define your own transformation 17 /// files are all examples of transformers. To define your own transformation
18 /// step, extend (or implement) this class. 18 /// step, extend (or implement) this class.
19 abstract class Transformer { 19 abstract class Transformer {
20 /// Returns `true` if [input] can be a primary input for this transformer. 20 /// Returns `true` if [input] can be a primary input for this transformer.
21 /// 21 ///
22 /// While a transformer can read from multiple input files, one must be the 22 /// While a transformer can read from multiple input files, one must be the
23 /// "primary" input. This asset determines whether the transformation should 23 /// "primary" input. This asset determines whether the transformation should
24 /// be run at all. If the primary input is removed, the transformer will no 24 /// be run at all. If the primary input is removed, the transformer will no
25 /// longer be run. 25 /// longer be run.
26 /// 26 ///
27 /// A concrete example is dart2js. When you run dart2js, it will traverse 27 /// A concrete example is dart2js. When you run dart2js, it will traverse
28 /// all of the imports in your Dart source files and use the contents of all 28 /// all of the imports in your Dart source files and use the contents of all
29 /// of those to generate the final JS. However you still run dart2js "on" a 29 /// of those to generate the final JS. However you still run dart2js "on" a
30 /// single file: the entrypoint Dart file that has your `main()` method. 30 /// single file: the entrypoint Dart file that has your `main()` method.
31 /// This entrypoint file would be the primary input. 31 /// This entrypoint file would be the primary input.
32 Future<bool> isPrimary(AssetId input); 32 Future<bool> isPrimary(Asset input);
33 33
34 /// Run this transformer on on the primary input specified by [transform]. 34 /// Run this transformer on on the primary input specified by [transform].
35 /// 35 ///
36 /// The [transform] is used by the [Transformer] for two purposes (in 36 /// The [transform] is used by the [Transformer] for two purposes (in
37 /// addition to accessing the primary input). It can call `getInput()` to 37 /// addition to accessing the primary input). It can call `getInput()` to
38 /// request additional input assets. It also calls `addOutput()` to provide 38 /// request additional input assets. It also calls `addOutput()` to provide
39 /// generated assets back to the system. Either can be called multiple times, 39 /// generated assets back to the system. Either can be called multiple times,
40 /// in any order. 40 /// in any order.
41 /// 41 ///
42 /// In other words, a Transformer's job is to find all inputs for a 42 /// In other words, a Transformer's job is to find all inputs for a
43 /// transform, starting at the primary input, then generate all output assets 43 /// transform, starting at the primary input, then generate all output assets
44 /// and yield them back to the transform. 44 /// and yield them back to the transform.
45 Future apply(Transform transform); 45 Future apply(Transform transform);
46 46
47 String toString() => runtimeType.toString().replaceAll("Transformer", ""); 47 String toString() => runtimeType.toString().replaceAll("Transformer", "");
48 } 48 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698