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

Unified Diff: sdk/lib/_internal/pub/test/serve/utils.dart

Issue 344673002: Load instances of the same transformer from the same isolate. (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/test/serve/utils.dart
diff --git a/sdk/lib/_internal/pub/test/serve/utils.dart b/sdk/lib/_internal/pub/test/serve/utils.dart
index a4763101fb94268f193fdf7ef74853e1ba29b063..d5dddd0d8d4f761b0181450635a16274a062c88d 100644
--- a/sdk/lib/_internal/pub/test/serve/utils.dart
+++ b/sdk/lib/_internal/pub/test/serve/utils.dart
@@ -98,6 +98,9 @@ const NOT_SERVED = 1;
/// If [import] is passed, it should be the name of a package that defines its
/// own TOKEN constant. The primary library of that package will be imported
/// here and its TOKEN value will be added to this library's.
+///
+/// This transformer takes one configuration field: "addition". This is
+/// concatenated to its TOKEN value before adding it to the output library.
String dartTransformer(String id, {String import}) {
if (import != null) {
id = '$id imports \${$import.TOKEN}';
@@ -112,12 +115,16 @@ import 'dart:async';
import 'package:barback/barback.dart';
$import
+import 'dart:io';
+
const TOKEN = "$id";
final _tokenRegExp = new RegExp(r'^const TOKEN = "(.*?)";\$', multiLine: true);
class DartTransformer extends Transformer {
- DartTransformer.asPlugin();
+ final BarbackSettings _settings;
+
+ DartTransformer.asPlugin(this._settings);
String get allowedExtensions => '.dart';
@@ -125,7 +132,10 @@ class DartTransformer extends Transformer {
return transform.primaryInput.readAsString().then((contents) {
transform.addOutput(new Asset.fromString(transform.primaryInput.id,
contents.replaceAllMapped(_tokenRegExp, (match) {
- return 'const TOKEN = "(\${match[1]}, \$TOKEN)";';
+ var token = TOKEN;
+ var addition = _settings.configuration["addition"];
+ if (addition != null) token += addition;
+ return 'const TOKEN = "(\${match[1]}, \$token)";';
})));
});
}

Powered by Google App Engine
This is Rietveld 408576698