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

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

Issue 223553008: Only pass an AssetId to isPrimary and declareOutputs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix script_compactor Created 6 years, 8 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/CHANGELOG.md ('k') | pkg/barback/lib/src/declaring_transform.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/base_transform.dart
diff --git a/pkg/barback/lib/src/base_transform.dart b/pkg/barback/lib/src/base_transform.dart
index c0de0f8ac26d5ee171f273cf6e593087aeaa6e3f..bb0183c5d74be119b6a0358a6fc70774dda9b3b8 100644
--- a/pkg/barback/lib/src/base_transform.dart
+++ b/pkg/barback/lib/src/base_transform.dart
@@ -5,16 +5,10 @@
library barback.base_transform;
import 'dart:async';
-import 'dart:convert';
-import 'asset.dart';
-import 'asset_id.dart';
-import 'asset_node.dart';
-import 'errors.dart';
import 'log.dart';
import 'transform_logger.dart';
import 'transform_node.dart';
-import 'utils.dart';
/// The base class for the ephemeral transform objects that are passed to
/// transformers.
@@ -47,29 +41,6 @@ abstract class BaseTransform {
TransformLogger get logger => _logger;
TransformLogger _logger;
- /// Gets the primary input asset.
- ///
- /// While a transformation can use multiple input assets, one must be a
- /// special "primary" asset. This will be the "entrypoint" or "main" input
- /// file for a transformation.
- ///
- /// For example, with a dart2js transform, the primary input would be the
- /// entrypoint Dart file. All of the other Dart files that that imports
- /// would be secondary inputs.
- ///
- /// This method may fail at runtime with an [AssetNotFoundException] if called
- /// asynchronously after the transform begins running. The primary input may
- /// become unavailable while this transformer is running due to asset changes
- /// earlier in the graph. You can ignore the error if this happens: the
- /// transformer will be re-run automatically for you.
- Asset get primaryInput {
- if (_node.primary.state != AssetState.AVAILABLE) {
- throw new AssetNotFoundException(_node.primary.id);
- }
-
- return _node.primary.asset;
- }
-
BaseTransform(this._node) {
_logger = new TransformLogger((asset, level, message, span) {
if (level == LogLevel.ERROR) _loggedError = true;
@@ -81,46 +52,6 @@ abstract class BaseTransform {
});
}
- /// Gets the asset for an input [id].
- ///
- /// If an input with [id] cannot be found, throws an [AssetNotFoundException].
- Future<Asset> getInput(AssetId id) => _node.getInput(id);
-
- /// A convenience method to the contents of the input with [id] as a string.
- ///
- /// This is equivalent to calling [getInput] followed by [Asset.readAsString].
- ///
- /// If the asset was created from a [String] the original string is always
- /// returned and [encoding] is ignored. Otherwise, the binary data of the
- /// asset is decoded using [encoding], which defaults to [UTF8].
- ///
- /// If an input with [id] cannot be found, throws an [AssetNotFoundException].
- Future<String> readInputAsString(AssetId id, {Encoding encoding}) {
- if (encoding == null) encoding = UTF8;
- return getInput(id).then((input) => input.readAsString(encoding: encoding));
- }
-
- /// A convenience method to the contents of the input with [id].
- ///
- /// This is equivalent to calling [getInput] followed by [Asset.read].
- ///
- /// If the asset was created from a [String], this returns its UTF-8 encoding.
- ///
- /// If an input with [id] cannot be found, throws an [AssetNotFoundException].
- Stream<List<int>> readInput(AssetId id) =>
- futureStream(getInput(id).then((input) => input.read()));
-
- /// A convenience method to return whether or not an asset exists.
- ///
- /// This is equivalent to calling [getInput] and catching an
- /// [AssetNotFoundException].
- Future<bool> hasInput(AssetId id) {
- return getInput(id).then((_) => true).catchError((error) {
- if (error is AssetNotFoundException && error.id == id) return false;
- throw error;
- });
- }
-
/// Consume the primary input so that it doesn't get processed by future
/// phases or emitted once processing has finished.
///
« no previous file with comments | « pkg/barback/CHANGELOG.md ('k') | pkg/barback/lib/src/declaring_transform.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698