| Index: sdk/lib/_internal/pub/lib/src/barback/excluding_transformer.dart
|
| diff --git a/sdk/lib/_internal/pub/lib/src/barback/excluding_transformer.dart b/sdk/lib/_internal/pub/lib/src/barback/excluding_transformer.dart
|
| index 1892f97a13d1b7b6a1550596d4835a6c6b64d5a8..2ba10fe4c23a493e58e604924b86a5d872416808 100644
|
| --- a/sdk/lib/_internal/pub/lib/src/barback/excluding_transformer.dart
|
| +++ b/sdk/lib/_internal/pub/lib/src/barback/excluding_transformer.dart
|
| @@ -8,56 +8,38 @@ import 'dart:async';
|
|
|
| import 'package:barback/barback.dart';
|
|
|
| +import '../barback.dart';
|
| +
|
| /// Decorates an inner [Transformer] and handles including and excluding
|
| /// primary inputs.
|
| class ExcludingTransformer extends Transformer {
|
| - /// If [includes] or [excludes] is non-null, wraps [inner] in an
|
| + /// If [id] defines includes or excludes, wraps [inner] in an
|
| /// [ExcludingTransformer] that handles those.
|
| ///
|
| /// Otherwise, just returns [inner] unmodified.
|
| - static Transformer wrap(Transformer inner, Set<String> includes,
|
| - Set<String> excludes) {
|
| - if (includes == null && excludes == null) return inner;
|
| + static Transformer wrap(Transformer inner, TransformerId id) {
|
| + if (!id.hasExclusions) return inner;
|
|
|
| if (inner is LazyTransformer) {
|
| // TODO(nweiz): Remove these unnecessary "as"es when issue 19046 is fixed.
|
| - return new _LazyExcludingTransformer(
|
| - inner as LazyTransformer, includes, excludes);
|
| + return new _LazyExcludingTransformer(inner as LazyTransformer, id);
|
| } else if (inner is DeclaringTransformer) {
|
| return new _DeclaringExcludingTransformer(
|
| - inner as DeclaringTransformer, includes, excludes);
|
| + inner as DeclaringTransformer, id);
|
| } else {
|
| - return new ExcludingTransformer._(inner, includes, excludes);
|
| + return new ExcludingTransformer._(inner, id);
|
| }
|
| }
|
|
|
| final Transformer _inner;
|
|
|
| - /// The set of asset paths which should be included.
|
| - ///
|
| - /// If `null`, all non-excluded assets are allowed. Otherwise, only included
|
| - /// assets are allowed.
|
| - final Set<String> _includes;
|
| -
|
| - /// The set of assets which should be excluded.
|
| - ///
|
| - /// Exclusions are applied after inclusions.
|
| - final Set<String> _excludes;
|
| + /// The id containing rules for which assets to include or exclude.
|
| + final TransformerId _id;
|
|
|
| - ExcludingTransformer._(this._inner, this._includes, this._excludes);
|
| + ExcludingTransformer._(this._inner, this._id);
|
|
|
| isPrimary(AssetId id) {
|
| - // TODO(rnystrom): Support globs in addition to paths. See #17093.
|
| - if (_includes != null) {
|
| - // If there are any includes, it must match one of them.
|
| - if (!_includes.contains(id.path)) return false;
|
| - }
|
| -
|
| - // It must not be excluded.
|
| - if (_excludes != null && _excludes.contains(id.path)) {
|
| - return false;
|
| - }
|
| -
|
| + if (!_id.canTransform(id.path)) return false;
|
| return _inner.isPrimary(id);
|
| }
|
|
|
| @@ -68,9 +50,8 @@ class ExcludingTransformer extends Transformer {
|
|
|
| class _DeclaringExcludingTransformer extends ExcludingTransformer
|
| implements DeclaringTransformer {
|
| - _DeclaringExcludingTransformer(DeclaringTransformer inner,
|
| - Set<String> includes, Set<String> excludes)
|
| - : super._(inner as Transformer, includes, excludes);
|
| + _DeclaringExcludingTransformer(DeclaringTransformer inner, TransformerId id)
|
| + : super._(inner as Transformer, id);
|
|
|
| Future declareOutputs(DeclaringTransform transform) =>
|
| (_inner as DeclaringTransformer).declareOutputs(transform);
|
| @@ -78,7 +59,6 @@ class _DeclaringExcludingTransformer extends ExcludingTransformer
|
|
|
| class _LazyExcludingTransformer extends _DeclaringExcludingTransformer
|
| implements LazyTransformer {
|
| - _LazyExcludingTransformer(DeclaringTransformer inner,
|
| - Set<String> includes, Set<String> excludes)
|
| - : super(inner, includes, excludes);
|
| + _LazyExcludingTransformer(DeclaringTransformer inner, TransformerId id)
|
| + : super(inner, id);
|
| }
|
|
|