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

Unified Diff: sdk/lib/_internal/pub/lib/src/barback.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
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/barback/excluding_aggregate_transformer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/barback.dart
diff --git a/sdk/lib/_internal/pub/lib/src/barback.dart b/sdk/lib/_internal/pub/lib/src/barback.dart
index 83b63de92b8f8cbc582889014261b7e1be6908fe..1c40a13f1e8eb9cf9eb37bae870064dc40eea334 100644
--- a/sdk/lib/_internal/pub/lib/src/barback.dart
+++ b/sdk/lib/_internal/pub/lib/src/barback.dart
@@ -89,6 +89,9 @@ class TransformerId {
/// Whether this ID points to a built-in transformer exposed by pub.
bool get isBuiltInTransformer => package.startsWith('\$');
+ /// Returns whether this id excludes certain asset ids from being processed.
+ bool get hasExclusions => includes != null || excludes != null;
+
/// Parses a transformer identifier.
///
/// A transformer identifier is a string of the form "package_name" or
@@ -193,6 +196,22 @@ class TransformerId {
.catchError((e) => new AssetId(package, 'lib/$package.dart'),
test: (e) => e is AssetNotFoundException);
}
+
+ /// Returns whether the include/exclude rules allow the transformer to run on
+ /// [pathWithinPackage].
+ ///
+ /// [pathWithinPackage] must be a path relative to the containing package's
+ /// root directory.
+ bool canTransform(String pathWithinPackage) {
+ // TODO(rnystrom): Support globs in addition to paths. See #17093.
+ if (excludes != null) {
+ // If there are any excludes, it must not match any of them.
+ if (excludes.contains(pathWithinPackage)) return false;
+ }
+
+ // If there are any includes, it must match one of them.
+ return includes == null || includes.contains(id.path);
+ }
}
/// Converts [id] to a "package:" URI.
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/barback/excluding_aggregate_transformer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698