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

Unified Diff: pkg/barback/lib/src/transformer.dart

Issue 16854005: First pass at build dependency graph for barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Handle unprovided sources and errors a bit better. Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/barback/lib/src/transform_node.dart ('k') | pkg/barback/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/transformer.dart
diff --git a/pkg/barback/lib/src/transformer.dart b/pkg/barback/lib/src/transformer.dart
new file mode 100644
index 0000000000000000000000000000000000000000..664d2e4c7fe1e202fbfda06588f466acce1d89ae
--- /dev/null
+++ b/pkg/barback/lib/src/transformer.dart
@@ -0,0 +1,48 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library barback.transformer;
+
+import 'dart:async';
+import 'dart:io';
+
+import 'asset_id.dart';
+import 'transform.dart';
+
+/// A [Transformer] represents a processor that takes in one or more input
+/// assets and uses them to generate one or more output assets.
+///
+/// Dart2js, a SASS->CSS processor, a CSS spriter, and a tool to concatenate
+/// files are all examples of transformers. To define your own transformation
+/// step, extend (or implement) this class.
+abstract class Transformer {
+ /// Returns `true` if [input] can be a primary input for this transformer.
+ ///
+ /// While a transformer can read from multiple input files, one must be the
+ /// "primary" input. This asset determines whether the transformation should
+ /// be run at all. If the primary input is removed, the transformer will no
+ /// longer be run.
+ ///
+ /// A concrete example is dart2js. When you run dart2js, it will traverse
+ /// all of the imports in your Dart source files and use the contents of all
+ /// of those to generate the final JS. However you still run dart2js "on" a
+ /// single file: the entrypoint Dart file that has your `main()` method.
+ /// This entrypoint file would be the primary input.
+ Future<bool> isPrimary(AssetId input);
+
+ /// Run this transformer on on the primary input specified by [transform].
+ ///
+ /// The [transform] is used by the [Transformer] for two purposes (in
+ /// addition to accessing the primary input). It can call `getInput()` to
+ /// request additional input assets. It also calls `addOutput()` to provide
+ /// generated assets back to the system. Either can be called multiple times,
+ /// in any order.
+ ///
+ /// In other words, a Transformer's job is to find all inputs for a
+ /// transform, starting at the primary input, then generate all output assets
+ /// and yield them back to the transform.
+ Future apply(Transform transform);
+
+ String toString() => runtimeType.toString().replaceAll("Transformer", "");
+}
« no previous file with comments | « pkg/barback/lib/src/transform_node.dart ('k') | pkg/barback/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698