| Index: pkg/barback/lib/src/transformer/declaring_transform.dart
|
| diff --git a/pkg/barback/lib/src/transformer/declaring_transform.dart b/pkg/barback/lib/src/transformer/declaring_transform.dart
|
| index e15082fc37ad6d33310bf029315385e20fab4c71..0c76546fb72f40be80c926acc4abf6a206a79e1d 100644
|
| --- a/pkg/barback/lib/src/transformer/declaring_transform.dart
|
| +++ b/pkg/barback/lib/src/transformer/declaring_transform.dart
|
| @@ -4,21 +4,32 @@
|
|
|
| library barback.transformer.declaring_transform;
|
|
|
| +import 'dart:async';
|
| +
|
| import '../asset/asset_id.dart';
|
| -import '../graph/transform_node.dart';
|
| -import 'base_transform.dart';
|
| +import 'declaring_aggregate_transform.dart';
|
| +import 'transform_logger.dart';
|
| +
|
| +/// Creates a new [DeclaringTransform] wrapping an
|
| +/// [AggregateDeclaringTransform].
|
| +Future<DeclaringTransform> newDeclaringTransform(
|
| + DeclaringAggregateTransform aggregate) {
|
| + return aggregate.primaryIds.first.then((primaryId) =>
|
| + new DeclaringTransform._(aggregate, primaryId));
|
| +}
|
|
|
| -/// A transform for [DeclaringTransform]ers that allows them to declare the ids
|
| +/// A transform for [DeclaringTransformer]s that allows them to declare the ids
|
| /// of the outputs they'll generate without generating the concrete bodies of
|
| /// those outputs.
|
| -class DeclaringTransform extends BaseTransform {
|
| - final _outputIds = new Set<AssetId>();
|
| +class DeclaringTransform {
|
| + final DeclaringAggregateTransform _aggregate;
|
|
|
| final AssetId primaryId;
|
|
|
| - DeclaringTransform._(TransformNode node)
|
| - : primaryId = node.primary.id,
|
| - super(node);
|
| + /// A logger so that the [Transformer] can report build details.
|
| + TransformLogger get logger => _aggregate.logger;
|
| +
|
| + DeclaringTransform._(this._aggregate, this.primaryId);
|
|
|
| /// Stores [id] as the id of an output that will be created by this
|
| /// transformation when it's run.
|
| @@ -27,21 +38,14 @@ class DeclaringTransform extends BaseTransform {
|
| /// [DeclaringTransformer.declareOutputs] declareds a given asset id for a
|
| /// given input, [Transformer.apply] should emit the corresponding asset as
|
| /// well.
|
| - void declareOutput(AssetId id) {
|
| - // TODO(nweiz): This should immediately throw if an output with that ID
|
| - // has already been declared by this transformer.
|
| - _outputIds.add(id);
|
| - }
|
| -}
|
| + void declareOutput(AssetId id) => _aggregate.declareOutput(id);
|
|
|
| -/// The controller for [DeclaringTransform].
|
| -class DeclaringTransformController extends BaseTransformController {
|
| - DeclaringTransform get transform => super.transform;
|
| -
|
| - /// The set of ids that the transformer declares it will emit for the given
|
| - /// primary input.
|
| - Set<AssetId> get outputIds => transform._outputIds;
|
| -
|
| - DeclaringTransformController(TransformNode node)
|
| - : super(new DeclaringTransform._(node));
|
| + /// Consume the primary input so that it doesn't get processed by future
|
| + /// phases or emitted once processing has finished.
|
| + ///
|
| + /// Normally the primary input will automatically be forwarded unless the
|
| + /// transformer overwrites it by emitting an input with the same id. This
|
| + /// allows the transformer to tell barback not to forward the primary input
|
| + /// even if it's not overwritten.
|
| + void consumePrimary() => _aggregate.consumePrimary(primaryId);
|
| }
|
|
|