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

Unified Diff: pkg/observe/lib/transformer.dart

Issue 63173009: Ensure we run the observable transform on PolymerElement (fixes issue 14942) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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/observe/lib/transform.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/transform.dart b/pkg/observe/lib/transformer.dart
similarity index 94%
copy from pkg/observe/lib/transform.dart
copy to pkg/observe/lib/transformer.dart
index 5e261c02b49b641fe30f36867373bd9a9ca3a9c5..3e6526baea64f02f02eb1d75284e188f4499d673 100644
--- a/pkg/observe/lib/transform.dart
+++ b/pkg/observe/lib/transformer.dart
@@ -6,7 +6,7 @@
* Code transform for @observable. The core transformation is relatively
* straightforward, and essentially like an editor refactoring.
*/
-library observe.transform;
+library observe.transformer;
import 'dart:async';
@@ -28,8 +28,33 @@ import 'package:source_maps/span.dart' show SourceFile;
*/
class ObservableTransformer extends Transformer {
+ final List<String> _files;
+ ObservableTransformer();
+ ObservableTransformer.asPlugin(BarbackSettings settings)
+ : _files = _readFiles(settings.configuration['files']);
+
+ static List<String> _readFiles(value) {
+ if (value == null) return null;
+ var files = [];
+ bool error;
+ if (value is List) {
+ files = value;
+ error = value.any((e) => e is! String);
+ } else if (value is String) {
+ files = [value];
+ error = false;
+ } else {
+ error = true;
+ }
+ if (error) print('Invalid value for "files" in the observe transformer.');
+ return files;
+ }
+
Future<bool> isPrimary(Asset input) {
- if (input.id.extension != '.dart') return new Future.value(false);
+ 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
« no previous file with comments | « pkg/observe/lib/transform.dart ('k') | pkg/observe/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698