Chromium Code Reviews| Index: sdk/lib/_internal/pub/lib/src/pubspec.dart |
| diff --git a/sdk/lib/_internal/pub/lib/src/pubspec.dart b/sdk/lib/_internal/pub/lib/src/pubspec.dart |
| index 56b012b84ae4e220f9fef5d84f1d547939760ca9..78041899b92a3f8aca834018081c973609d40934 100644 |
| --- a/sdk/lib/_internal/pub/lib/src/pubspec.dart |
| +++ b/sdk/lib/_internal/pub/lib/src/pubspec.dart |
| @@ -4,6 +4,7 @@ |
| library pub.pubspec; |
| +import 'package:barback/barback.dart'; |
| import 'package:yaml/yaml.dart'; |
| import 'package:path/path.dart' as path; |
| @@ -28,6 +29,10 @@ class Pubspec { |
| /// The packages this package depends on when it is the root package. |
| final List<PackageDep> devDependencies; |
| + /// The ids of the libraries containing the transformers to use for this |
| + /// package. |
| + final List<Set<AssetId>> transformers; |
| + |
| /// The environment-related metadata. |
| final PubspecEnvironment environment; |
| @@ -59,7 +64,7 @@ class Pubspec { |
| } |
| Pubspec(this.name, this.version, this.dependencies, this.devDependencies, |
| - this.environment, [Map<String, Object> fields]) |
| + this.environment, this.transformers, [Map<String, Object> fields]) |
| : this.fields = fields == null ? {} : fields; |
| Pubspec.empty() |
| @@ -68,6 +73,7 @@ class Pubspec { |
| dependencies = <PackageDep>[], |
| devDependencies = <PackageDep>[], |
| environment = new PubspecEnvironment(), |
| + transformers = <Set<AssetId>>[], |
| fields = {}; |
| /// Whether or not the pubspec has no contents. |
| @@ -173,6 +179,36 @@ Pubspec _parseMap(String filePath, Map map, SourceRegistry sources) { |
| '"dev_dependencies".'); |
| } |
| + var transformers = map['transformers']; |
| + if (transformers != null) { |
| + if (transformers is! List) { |
| + throw new FormatException('Transformers "$transformers" must be a list.'); |
|
Bob Nystrom
2013/08/27 22:12:30
'The pubspec field "transformers" must be a list,
nweiz
2013/08/28 20:45:23
I don't like explicitly calling out that this is a
Bob Nystrom
2013/08/29 00:12:01
The other messages in here provide that context ex
nweiz
2013/09/04 00:21:58
The existing messages are already inconsistent. I'
|
| + } |
| + |
| + transformers = transformers.map((phase) { |
| + if (phase is! List) phase = [phase]; |
| + return phase.map((transformer) { |
| + if (transformer is! String) { |
| + throw new FormatException( |
| + 'Transformer "$transformer" must be a string.'); |
| + } |
| + |
| + var parts = split1(transformer, "/"); |
|
Bob Nystrom
2013/08/27 22:12:30
Document this chunk of code.
Also, can you file a
nweiz
2013/08/28 20:45:23
Done.
|
| + if (parts.length == 1) parts.add(parts.single); |
| + var id = new AssetId(parts.first, 'lib/' + parts.last + '.dart'); |
| + |
| + if (id.package != name && |
| + !dependencies.any((ref) => ref.name == id.package)) { |
| + throw new FormatException('Transformer "$transformer" not found.'); |
|
Bob Nystrom
2013/08/27 22:12:30
Clarify this message, like 'Could not find package
nweiz
2013/08/28 20:45:23
Done.
|
| + } |
| + |
| + return id; |
| + }).toSet(); |
| + }).toList(); |
| + } else { |
| + transformers = []; |
| + } |
| + |
| var environmentYaml = map['environment']; |
| var sdkConstraint = VersionConstraint.any; |
| if (environmentYaml != null) { |
| @@ -232,7 +268,7 @@ Pubspec _parseMap(String filePath, Map map, SourceRegistry sources) { |
| } |
| return new Pubspec(name, version, dependencies, devDependencies, |
| - environment, map); |
| + environment, transformers, map); |
| } |
| /// Parses [yaml] to a [Version] or throws a [FormatException] with the result |