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

Side by Side Diff: lib/src/pubspec.dart

Issue 2184303002: Make pub strong-mode clean. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « lib/src/package_graph.dart ('k') | lib/src/solver/backtracking_solver.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'package:path/path.dart' as path; 5 import 'package:path/path.dart' as path;
6 import 'package:pub_semver/pub_semver.dart'; 6 import 'package:pub_semver/pub_semver.dart';
7 import 'package:source_span/source_span.dart'; 7 import 'package:source_span/source_span.dart';
8 import 'package:yaml/yaml.dart'; 8 import 'package:yaml/yaml.dart';
9 9
10 import 'barback/transformer_config.dart'; 10 import 'barback/transformer_config.dart';
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 if (transformers == null) { 144 if (transformers == null) {
145 _transformers = []; 145 _transformers = [];
146 return _transformers; 146 return _transformers;
147 } 147 }
148 148
149 if (transformers is! List) { 149 if (transformers is! List) {
150 _error('"transformers" field must be a list.', 150 _error('"transformers" field must be a list.',
151 fields.nodes['transformers'].span); 151 fields.nodes['transformers'].span);
152 } 152 }
153 153
154 _transformers = transformers.nodes.map((phase) { 154 _transformers = (transformers as YamlList).nodes.map((phase) {
155 var phaseNodes = phase is YamlList ? phase.nodes : [phase]; 155 var phaseNodes = phase is YamlList ? phase.nodes : [phase];
156 return phaseNodes.map((transformerNode) { 156 return phaseNodes.map((transformerNode) {
157 var transformer = transformerNode.value; 157 var transformer = transformerNode.value;
158 if (transformer is! String && transformer is! Map) { 158 if (transformer is! String && transformer is! Map) {
159 _error('A transformer must be a string or map.', 159 _error('A transformer must be a string or map.',
160 transformerNode.span); 160 transformerNode.span);
161 } 161 }
162 162
163 var libraryNode; 163 var libraryNode;
164 var configurationNode; 164 var configurationNode;
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 '"$expectedName".', this.fields.nodes["name"].span); 421 '"$expectedName".', this.fields.nodes["name"].span);
422 } 422 }
423 423
424 /// Parses the pubspec stored at [filePath] whose text is [contents]. 424 /// Parses the pubspec stored at [filePath] whose text is [contents].
425 /// 425 ///
426 /// If the pubspec doesn't define a version for itself, it defaults to 426 /// If the pubspec doesn't define a version for itself, it defaults to
427 /// [Version.none]. 427 /// [Version.none].
428 factory Pubspec.parse(String contents, SourceRegistry sources, 428 factory Pubspec.parse(String contents, SourceRegistry sources,
429 {String expectedName, Uri location}) { 429 {String expectedName, Uri location}) {
430 var pubspecNode = loadYamlNode(contents, sourceUrl: location); 430 var pubspecNode = loadYamlNode(contents, sourceUrl: location);
431 Map pubspecMap;
431 if (pubspecNode is YamlScalar && pubspecNode.value == null) { 432 if (pubspecNode is YamlScalar && pubspecNode.value == null) {
432 pubspecNode = new YamlMap(sourceUrl: location); 433 pubspecMap = new YamlMap(sourceUrl: location);
433 } else if (pubspecNode is! YamlMap) { 434 } else if (pubspecNode is YamlMap) {
435 pubspecMap = pubspecNode;
436 } else {
434 throw new PubspecException( 437 throw new PubspecException(
435 'The pubspec must be a YAML mapping.', pubspecNode.span); 438 'The pubspec must be a YAML mapping.', pubspecNode.span);
436 } 439 }
437 440
438 return new Pubspec.fromMap(pubspecNode, sources, 441 return new Pubspec.fromMap(pubspecMap, sources,
439 expectedName: expectedName, location: location); 442 expectedName: expectedName, location: location);
440 } 443 }
441 444
442 /// Returns a list of most errors in this pubspec. 445 /// Returns a list of most errors in this pubspec.
443 /// 446 ///
444 /// This will return at most one error for each field. 447 /// This will return at most one error for each field.
445 List<PubspecException> get allErrors { 448 List<PubspecException> get allErrors {
446 var errors = <PubspecException>[]; 449 var errors = <PubspecException>[];
447 _getError(fn()) { 450 _getError(fn()) {
448 try { 451 try {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 implements ApplicationException { 618 implements ApplicationException {
616 PubspecException(String message, SourceSpan span) 619 PubspecException(String message, SourceSpan span)
617 : super(message, span); 620 : super(message, span);
618 } 621 }
619 622
620 /// Returns whether [uri] is a file URI. 623 /// Returns whether [uri] is a file URI.
621 /// 624 ///
622 /// This is slightly more complicated than just checking if the scheme is 625 /// This is slightly more complicated than just checking if the scheme is
623 /// 'file', since relative URIs also refer to the filesystem on the VM. 626 /// 'file', since relative URIs also refer to the filesystem on the VM.
624 bool _isFileUri(Uri uri) => uri.scheme == 'file' || uri.scheme == ''; 627 bool _isFileUri(Uri uri) => uri.scheme == 'file' || uri.scheme == '';
OLDNEW
« no previous file with comments | « lib/src/package_graph.dart ('k') | lib/src/solver/backtracking_solver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698