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

Unified Diff: pkg/observe/lib/transformer.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/code_transformers/test/resolver_test.dart ('k') | pkg/observe/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/observe/lib/transformer.dart
diff --git a/pkg/observe/lib/transformer.dart b/pkg/observe/lib/transformer.dart
index 2c5a17e2b475b49f2cba2f803b2da414f57efc16..776cc3f4b326419b21991899c29d94c49f92c6f4 100644
--- a/pkg/observe/lib/transformer.dart
+++ b/pkg/observe/lib/transformer.dart
@@ -45,22 +45,23 @@ class ObservableTransformer extends Transformer {
return files;
}
- Future<bool> isPrimary(Asset input) {
- if (input.id.extension != '.dart' ||
- (_files != null && !_files.contains(input.id.path))) {
- return new Future.value(false);
- }
- // Note: technically we should parse the file to find accurately the
- // observable annotation, but that seems expensive. It would require almost
- // as much work as applying the transform. We rather have some false
- // positives here, and then generate no outputs when we apply this
- // transform.
- return input.readAsString().then(
- (c) => c.contains("@observable") || c.contains("@published"));
+ // TODO(nweiz): This should just take an AssetId when barback <0.13.0 support
+ // is dropped.
+ Future<bool> isPrimary(idOrAsset) {
+ var id = idOrAsset is AssetId ? idOrAsset : idOrAsset.id;
+ return new Future.value(id.extension == '.dart' &&
+ (_files == null || _files.contains(id.path)));
}
Future apply(Transform transform) {
return transform.primaryInput.readAsString().then((content) {
+ // Do a quick string check to determine if this is this file even
+ // plausibly might need to be transformed. If not, we can avoid an
+ // expensive parse.
+ if (!content.contains("@observable") && !content.contains("@published")) {
+ return;
+ }
+
var id = transform.primaryInput.id;
// TODO(sigmund): improve how we compute this url
var url = id.path.startsWith('lib/')
« no previous file with comments | « pkg/code_transformers/test/resolver_test.dart ('k') | pkg/observe/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698