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

Unified Diff: sdk/lib/_internal/pub/lib/src/barback/excluding_aggregate_transformer.dart

Issue 328033002: Move include/exclude calculations to the TransformerId class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 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
Index: sdk/lib/_internal/pub/lib/src/barback/excluding_aggregate_transformer.dart
diff --git a/sdk/lib/_internal/pub/lib/src/barback/excluding_aggregate_transformer.dart b/sdk/lib/_internal/pub/lib/src/barback/excluding_aggregate_transformer.dart
index 8a5983992cdabb2ef5c2091de53c2632de7c205f..47e4e9e5cf739a9796791859a2e7649d6db02fa9 100644
--- a/sdk/lib/_internal/pub/lib/src/barback/excluding_aggregate_transformer.dart
+++ b/sdk/lib/_internal/pub/lib/src/barback/excluding_aggregate_transformer.dart
@@ -8,55 +8,39 @@ import 'dart:async';
import 'package:barback/barback.dart';
+import '../barback.dart';
+
/// Decorates an inner [AggregateTransformer] and handles including and
/// excluding primary inputs.
class ExcludingAggregateTransformer extends AggregateTransformer {
- /// If [includes] or [excludes] is non-null, wraps [inner] in an
+ /// If [id] defines includes or excludes, wraps [inner] in an
/// [ExcludingAggregateTransformer] that handles those.
///
/// Otherwise, just returns [inner] unmodified.
static AggregateTransformer wrap(AggregateTransformer inner,
- Set<String> includes, Set<String> excludes) {
- if (includes == null && excludes == null) return inner;
+ TransformerId id) {
+ if (!id.hasExclusions) return inner;
if (inner is LazyAggregateTransformer) {
return new _LazyExcludingAggregateTransformer(
- inner as LazyAggregateTransformer, includes, excludes);
+ inner as LazyAggregateTransformer, id);
} else if (inner is DeclaringAggregateTransformer) {
return new _DeclaringExcludingAggregateTransformer(
- inner as DeclaringAggregateTransformer, includes, excludes);
+ inner as DeclaringAggregateTransformer, id);
} else {
- return new ExcludingAggregateTransformer._(inner, includes, excludes);
+ return new ExcludingAggregateTransformer._(inner, id);
}
}
final AggregateTransformer _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;
- ExcludingAggregateTransformer._(this._inner, this._includes, this._excludes);
+ ExcludingAggregateTransformer._(this._inner, this._id);
classifyPrimary(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 null;
- }
-
- // It must not be excluded.
- if (_excludes != null && _excludes.contains(id.path)) {
- return null;
- }
-
+ if (!_id.canTransform(id.path)) return null;
return _inner.classifyPrimary(id);
}
@@ -69,8 +53,8 @@ class _DeclaringExcludingAggregateTransformer
extends ExcludingAggregateTransformer
implements DeclaringAggregateTransformer {
_DeclaringExcludingAggregateTransformer(DeclaringAggregateTransformer inner,
- Set<String> includes, Set<String> excludes)
- : super._(inner as AggregateTransformer, includes, excludes);
+ TransformerId id)
+ : super._(inner as AggregateTransformer, id);
Future declareOutputs(DeclaringAggregateTransform transform) =>
(_inner as DeclaringAggregateTransformer).declareOutputs(transform);
@@ -80,6 +64,6 @@ class _LazyExcludingAggregateTransformer
extends _DeclaringExcludingAggregateTransformer
implements LazyAggregateTransformer {
_LazyExcludingAggregateTransformer(DeclaringAggregateTransformer inner,
- Set<String> includes, Set<String> excludes)
- : super(inner, includes, excludes);
+ TransformerId id)
+ : super(inner, id);
}
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/barback.dart ('k') | sdk/lib/_internal/pub/lib/src/barback/excluding_transformer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698