| Index: sdk/lib/_internal/pub_generated/lib/src/pubspec.dart
|
| diff --git a/sdk/lib/_internal/pub/lib/src/pubspec.dart b/sdk/lib/_internal/pub_generated/lib/src/pubspec.dart
|
| similarity index 78%
|
| copy from sdk/lib/_internal/pub/lib/src/pubspec.dart
|
| copy to sdk/lib/_internal/pub_generated/lib/src/pubspec.dart
|
| index c772402d8641f114c0fa2736ddb86cf8ae064fb2..92c068a7b5fa160ad126b99c892614f36cfc76c8 100644
|
| --- a/sdk/lib/_internal/pub/lib/src/pubspec.dart
|
| +++ b/sdk/lib/_internal/pub_generated/lib/src/pubspec.dart
|
| @@ -52,10 +52,12 @@ class Pubspec {
|
| var name = fields['name'];
|
| if (name == null) {
|
| throw new PubspecException(
|
| - 'Missing the required "name" field.', fields.span);
|
| + 'Missing the required "name" field.',
|
| + fields.span);
|
| } else if (name is! String) {
|
| throw new PubspecException(
|
| - '"name" field must be a string.', fields.nodes['name'].span);
|
| + '"name" field must be a string.',
|
| + fields.nodes['name'].span);
|
| }
|
|
|
| _name = name;
|
| @@ -79,15 +81,17 @@ class Pubspec {
|
| if (version is int) {
|
| fixed = '$fixed.0';
|
| }
|
| - _error('"version" field must have three numeric components: major, '
|
| - 'minor, and patch. Instead of "$version", consider "$fixed".', span);
|
| + _error(
|
| + '"version" field must have three numeric components: major, '
|
| + 'minor, and patch. Instead of "$version", consider "$fixed".',
|
| + span);
|
| }
|
| if (version is! String) {
|
| _error('"version" field must be a string.', span);
|
| }
|
|
|
| - _version = _wrapFormatException('version number', span,
|
| - () => new Version.parse(version));
|
| + _version =
|
| + _wrapFormatException('version number', span, () => new Version.parse(version));
|
| return _version;
|
| }
|
| Version _version;
|
| @@ -133,7 +137,8 @@ class Pubspec {
|
| }
|
|
|
| if (transformers is! List) {
|
| - _error('"transformers" field must be a list.',
|
| + _error(
|
| + '"transformers" field must be a list.',
|
| fields.nodes['transformers'].span);
|
| }
|
|
|
| @@ -143,8 +148,9 @@ class Pubspec {
|
| return phaseNodes.map((transformerNode) {
|
| var transformer = transformerNode.value;
|
| if (transformer is! String && transformer is! Map) {
|
| - _error('A transformer must be a string or map.',
|
| - transformerNode.span);
|
| + _error(
|
| + 'A transformer must be a string or map.',
|
| + transformerNode.span);
|
| }
|
|
|
| var libraryNode;
|
| @@ -153,25 +159,29 @@ class Pubspec {
|
| libraryNode = transformerNode;
|
| } else {
|
| if (transformer.length != 1) {
|
| - _error('A transformer map must have a single key: the transformer '
|
| - 'identifier.', transformerNode.span);
|
| + _error(
|
| + 'A transformer map must have a single key: the transformer ' 'identifier.',
|
| + transformerNode.span);
|
| } else if (transformer.keys.single is! String) {
|
| - _error('A transformer identifier must be a string.',
|
| + _error(
|
| + 'A transformer identifier must be a string.',
|
| transformer.nodes.keys.single.span);
|
| }
|
|
|
| libraryNode = transformer.nodes.keys.single;
|
| configurationNode = transformer.nodes.values.single;
|
| if (configurationNode is! YamlMap) {
|
| - _error("A transformer's configuration must be a map.",
|
| + _error(
|
| + "A transformer's configuration must be a map.",
|
| configurationNode.span);
|
| }
|
| }
|
|
|
| var config = _wrapSpanFormatException('transformer config', () {
|
| return new TransformerConfig.parse(
|
| - libraryNode.value, libraryNode.span,
|
| - configurationNode);
|
| + libraryNode.value,
|
| + libraryNode.span,
|
| + configurationNode);
|
| });
|
|
|
| var package = config.id.package;
|
| @@ -180,8 +190,7 @@ class Pubspec {
|
| !dependencies.any((ref) => ref.name == package) &&
|
| !devDependencies.any((ref) => ref.name == package) &&
|
| !dependencyOverrides.any((ref) => ref.name == package)) {
|
| - _error('"$package" is not a dependency.',
|
| - libraryNode.span);
|
| + _error('"$package" is not a dependency.', libraryNode.span);
|
| }
|
|
|
| return config;
|
| @@ -203,12 +212,13 @@ class Pubspec {
|
| }
|
|
|
| if (yaml is! Map) {
|
| - _error('"environment" field must be a map.',
|
| - fields.nodes['environment'].span);
|
| + _error(
|
| + '"environment" field must be a map.',
|
| + fields.nodes['environment'].span);
|
| }
|
|
|
| - _environment = new PubspecEnvironment(
|
| - _parseVersionConstraint(yaml.nodes['sdk']));
|
| + _environment =
|
| + new PubspecEnvironment(_parseVersionConstraint(yaml.nodes['sdk']));
|
| return _environment;
|
| }
|
| PubspecEnvironment _environment;
|
| @@ -231,7 +241,9 @@ class Pubspec {
|
|
|
| // It must be "none" or a valid URL.
|
| if (publishTo != "none") {
|
| - _wrapFormatException('"publish_to" field', span,
|
| + _wrapFormatException(
|
| + '"publish_to" field',
|
| + span,
|
| () => Uri.parse(publishTo));
|
| }
|
| }
|
| @@ -260,7 +272,8 @@ class Pubspec {
|
| if (yaml == null) return _executables;
|
|
|
| if (yaml is! Map) {
|
| - _error('"executables" field must be a map.',
|
| + _error(
|
| + '"executables" field must be a map.',
|
| fields.nodes['executables'].span);
|
| }
|
|
|
| @@ -275,8 +288,10 @@ class Pubspec {
|
|
|
| final keyPattern = new RegExp(r"^[a-zA-Z0-9_-]+$");
|
| if (!keyPattern.hasMatch(key.value)) {
|
| - _error('"executables" keys may only contain letters, '
|
| - 'numbers, hyphens and underscores.', key.span);
|
| + _error(
|
| + '"executables" keys may only contain letters, '
|
| + 'numbers, hyphens and underscores.',
|
| + key.span);
|
| }
|
|
|
| if (value.value == null) {
|
| @@ -287,7 +302,8 @@ class Pubspec {
|
|
|
| final valuePattern = new RegExp(r"[/\\]");
|
| if (valuePattern.hasMatch(value.value)) {
|
| - _error('"executables" values may not contain path separators.',
|
| + _error(
|
| + '"executables" values may not contain path separators.',
|
| value.span);
|
| }
|
|
|
| @@ -305,7 +321,7 @@ class Pubspec {
|
|
|
| /// Whether or not the pubspec has no contents.
|
| bool get isEmpty =>
|
| - name == null && version == Version.none && dependencies.isEmpty;
|
| + name == null && version == Version.none && dependencies.isEmpty;
|
|
|
| /// Loads the pubspec for a package located in [packageDir].
|
| ///
|
| @@ -321,37 +337,42 @@ class Pubspec {
|
| pubspecPath);
|
| }
|
|
|
| - return new Pubspec.parse(readTextFile(pubspecPath), sources,
|
| - expectedName: expectedName, location: pubspecUri);
|
| + return new Pubspec.parse(
|
| + readTextFile(pubspecPath),
|
| + sources,
|
| + expectedName: expectedName,
|
| + location: pubspecUri);
|
| }
|
|
|
| Pubspec(this._name, {Version version, Iterable<PackageDep> dependencies,
|
| - Iterable<PackageDep> devDependencies,
|
| - Iterable<PackageDep> dependencyOverrides,
|
| - VersionConstraint sdkConstraint,
|
| - Iterable<Iterable<TransformerConfig>> transformers,
|
| - Map fields, SourceRegistry sources})
|
| + Iterable<PackageDep> devDependencies, Iterable<PackageDep> dependencyOverrides,
|
| + VersionConstraint sdkConstraint,
|
| + Iterable<Iterable<TransformerConfig>> transformers, Map fields,
|
| + SourceRegistry sources})
|
| : _version = version,
|
| _dependencies = dependencies == null ? null : dependencies.toList(),
|
| - _devDependencies = devDependencies == null ? null :
|
| - devDependencies.toList(),
|
| - _dependencyOverrides = dependencyOverrides == null ? null :
|
| - dependencyOverrides.toList(),
|
| + _devDependencies = devDependencies == null ?
|
| + null :
|
| + devDependencies.toList(),
|
| + _dependencyOverrides = dependencyOverrides == null ?
|
| + null :
|
| + dependencyOverrides.toList(),
|
| _environment = new PubspecEnvironment(sdkConstraint),
|
| - _transformers = transformers == null ? [] :
|
| - transformers.map((phase) => phase.toSet()).toList(),
|
| + _transformers = transformers == null ?
|
| + [] :
|
| + transformers.map((phase) => phase.toSet()).toList(),
|
| fields = fields == null ? new YamlMap() : new YamlMap.wrap(fields),
|
| _sources = sources;
|
|
|
| Pubspec.empty()
|
| - : _sources = null,
|
| - _name = null,
|
| - _version = Version.none,
|
| - _dependencies = <PackageDep>[],
|
| - _devDependencies = <PackageDep>[],
|
| - _environment = new PubspecEnvironment(),
|
| - _transformers = <Set<TransformerConfig>>[],
|
| - fields = new YamlMap();
|
| + : _sources = null,
|
| + _name = null,
|
| + _version = Version.none,
|
| + _dependencies = <PackageDep>[],
|
| + _devDependencies = <PackageDep>[],
|
| + _environment = new PubspecEnvironment(),
|
| + _transformers = <Set<TransformerConfig>>[],
|
| + fields = new YamlMap();
|
|
|
| /// Returns a Pubspec object for an already-parsed map representing its
|
| /// contents.
|
| @@ -362,15 +383,17 @@ class Pubspec {
|
| /// [location] is the location from which this pubspec was loaded.
|
| Pubspec.fromMap(Map fields, this._sources, {String expectedName,
|
| Uri location})
|
| - : fields = fields is YamlMap ? fields :
|
| - new YamlMap.wrap(fields, sourceUrl: location) {
|
| + : fields = fields is YamlMap ?
|
| + fields :
|
| + new YamlMap.wrap(fields, sourceUrl: location) {
|
| // If [expectedName] is passed, ensure that the actual 'name' field exists
|
| // and matches the expectation.
|
| if (expectedName == null) return;
|
| if (name == expectedName) return;
|
|
|
| - throw new PubspecException('"name" field doesn\'t match expected name '
|
| - '"$expectedName".', this.fields.nodes["name"].span);
|
| + throw new PubspecException(
|
| + '"name" field doesn\'t match expected name ' '"$expectedName".',
|
| + this.fields.nodes["name"].span);
|
| }
|
|
|
| /// Parses the pubspec stored at [filePath] whose text is [contents].
|
| @@ -384,11 +407,15 @@ class Pubspec {
|
| pubspecNode = new YamlMap(sourceUrl: location);
|
| } else if (pubspecNode is! YamlMap) {
|
| throw new PubspecException(
|
| - 'The pubspec must be a YAML mapping.', pubspecNode.span);
|
| + 'The pubspec must be a YAML mapping.',
|
| + pubspecNode.span);
|
| }
|
|
|
| - return new Pubspec.fromMap(pubspecNode, sources,
|
| - expectedName: expectedName, location: location);
|
| + return new Pubspec.fromMap(
|
| + pubspecNode,
|
| + sources,
|
| + expectedName: expectedName,
|
| + location: location);
|
| }
|
|
|
| /// Returns a list of most errors in this pubspec.
|
| @@ -427,8 +454,8 @@ class Pubspec {
|
| _error('"$field" field must be a map.', fields.nodes[field].span);
|
| }
|
|
|
| - var nonStringNode = yaml.nodes.keys.firstWhere((e) => e.value is! String,
|
| - orElse: () => null);
|
| + var nonStringNode =
|
| + yaml.nodes.keys.firstWhere((e) => e.value is! String, orElse: () => null);
|
| if (nonStringNode != null) {
|
| _error('A dependency name must be a string.', nonStringNode.span);
|
| }
|
| @@ -437,8 +464,7 @@ class Pubspec {
|
| var name = nameNode.value;
|
| var spec = specNode.value;
|
| if (fields['name'] != null && name == this.name) {
|
| - _error('A package may not list itself as a dependency.',
|
| - nameNode.span);
|
| + _error('A package may not list itself as a dependency.', nameNode.span);
|
| }
|
|
|
| var descriptionNode;
|
| @@ -458,8 +484,8 @@ class Pubspec {
|
|
|
| if (spec.containsKey('version')) {
|
| spec.remove('version');
|
| - versionConstraint = _parseVersionConstraint(
|
| - specNode.nodes['version']);
|
| + versionConstraint =
|
| + _parseVersionConstraint(specNode.nodes['version']);
|
| }
|
|
|
| var sourceNames = spec.keys.toList();
|
| @@ -469,30 +495,34 @@ class Pubspec {
|
|
|
| sourceName = sourceNames.single;
|
| if (sourceName is! String) {
|
| - _error('A source name must be a string.',
|
| + _error(
|
| + 'A source name must be a string.',
|
| specNode.nodes.keys.single.span);
|
| }
|
|
|
| descriptionNode = specNode.nodes[sourceName];
|
| } else {
|
| - _error('A dependency specification must be a string or a mapping.',
|
| + _error(
|
| + 'A dependency specification must be a string or a mapping.',
|
| specNode.span);
|
| }
|
|
|
| // Let the source validate the description.
|
| - var description = _wrapFormatException('description',
|
| - descriptionNode.span, () {
|
| + var description =
|
| + _wrapFormatException('description', descriptionNode.span, () {
|
| var pubspecPath;
|
| if (_location != null && _isFileUri(_location)) {
|
| pubspecPath = path.fromUri(_location);
|
| }
|
|
|
| return _sources[sourceName].parseDescription(
|
| - pubspecPath, descriptionNode.value, fromLockFile: false);
|
| + pubspecPath,
|
| + descriptionNode.value,
|
| + fromLockFile: false);
|
| });
|
|
|
| - dependencies.add(new PackageDep(
|
| - name, sourceName, versionConstraint, description));
|
| + dependencies.add(
|
| + new PackageDep(name, sourceName, versionConstraint, description));
|
| });
|
|
|
| return dependencies;
|
| @@ -505,7 +535,9 @@ class Pubspec {
|
| _error('A version constraint must be a string.', node.span);
|
| }
|
|
|
| - return _wrapFormatException('version constraint', node.span,
|
| + return _wrapFormatException(
|
| + 'version constraint',
|
| + node.span,
|
| () => new VersionConstraint.parse(node.value));
|
| }
|
|
|
| @@ -517,18 +549,19 @@ class Pubspec {
|
| if (devDependencies == null) return;
|
|
|
| var dependencyNames = dependencies.map((dep) => dep.name).toSet();
|
| - var collisions = dependencyNames.intersection(
|
| - devDependencies.map((dep) => dep.name).toSet());
|
| + var collisions =
|
| + dependencyNames.intersection(devDependencies.map((dep) => dep.name).toSet());
|
| if (collisions.isEmpty) return;
|
|
|
| - var span = fields["dependencies"].nodes.keys
|
| - .firstWhere((key) => collisions.contains(key.value)).span;
|
| + var span = fields["dependencies"].nodes.keys.firstWhere(
|
| + (key) => collisions.contains(key.value)).span;
|
|
|
| // TODO(nweiz): associate source range info with PackageDeps and use it
|
| // here.
|
| - _error('${pluralize('Package', collisions.length)} '
|
| - '${toSentence(collisions.map((package) => '"$package"'))} cannot '
|
| - 'appear in both "dependencies" and "dev_dependencies".',
|
| + _error(
|
| + '${pluralize('Package', collisions.length)} '
|
| + '${toSentence(collisions.map((package) => '"$package"'))} cannot '
|
| + 'appear in both "dependencies" and "dev_dependencies".',
|
| span);
|
| }
|
|
|
| @@ -582,8 +615,8 @@ class PubspecEnvironment {
|
| /// An exception thrown when parsing a pubspec.
|
| ///
|
| /// These exceptions are often thrown lazily while accessing pubspec properties.
|
| -class PubspecException extends SourceSpanFormatException
|
| - implements ApplicationException {
|
| +class PubspecException extends SourceSpanFormatException implements
|
| + ApplicationException {
|
| PubspecException(String message, SourceSpan span)
|
| : super(message, span);
|
| }
|
|
|