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

Side by Side Diff: utils/pub/version_solver.dart

Issue 10854191: Require two type arguments for map literals (issue 4522). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « utils/pub/source_registry.dart ('k') | utils/pub/yaml/composer.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 /** 5 /**
6 * Attempts to resolve a set of version constraints for a package dependency 6 * Attempts to resolve a set of version constraints for a package dependency
7 * graph and select an appropriate set of best specific versions for all 7 * graph and select an appropriate set of best specific versions for all
8 * dependent packages. It works iteratively and tries to reach a stable 8 * dependent packages. It works iteratively and tries to reach a stable
9 * solution where the constraints of all dependencies are met. If it fails to 9 * solution where the constraints of all dependencies are met. If it fails to
10 * reach a solution after a certain number of iterations, it assumes the 10 * reach a solution after a certain number of iterations, it assumes the
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 final Package _root; 66 final Package _root;
67 final LockFile lockFile; 67 final LockFile lockFile;
68 final PubspecCache _pubspecs; 68 final PubspecCache _pubspecs;
69 final Map<String, Dependency> _packages; 69 final Map<String, Dependency> _packages;
70 final Queue<WorkItem> _work; 70 final Queue<WorkItem> _work;
71 int _numIterations = 0; 71 int _numIterations = 0;
72 72
73 VersionSolver(SourceRegistry sources, this._root, this.lockFile) 73 VersionSolver(SourceRegistry sources, this._root, this.lockFile)
74 : _sources = sources, 74 : _sources = sources,
75 _pubspecs = new PubspecCache(sources), 75 _pubspecs = new PubspecCache(sources),
76 _packages = <Dependency>{}, 76 _packages = <String, Dependency>{},
77 _work = new Queue<WorkItem>(); 77 _work = new Queue<WorkItem>();
78 78
79 Future<List<PackageId>> solve() { 79 Future<List<PackageId>> solve() {
80 // Kick off the work by adding the root package at its concrete version to 80 // Kick off the work by adding the root package at its concrete version to
81 // the dependency graph. 81 // the dependency graph.
82 var ref = new PackageRef(new RootSource(_root), _root.version, _root.name); 82 var ref = new PackageRef(new RootSource(_root), _root.version, _root.name);
83 enqueue(new AddConstraint('(entrypoint)', ref)); 83 enqueue(new AddConstraint('(entrypoint)', ref));
84 _pubspecs.cache(ref.atVersion(_root.version), _root.pubspec); 84 _pubspecs.cache(ref.atVersion(_root.version), _root.pubspec);
85 85
86 Future processNextWorkItem(_) { 86 Future processNextWorkItem(_) {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 }); 229 });
230 } 230 }
231 231
232 /** 232 /**
233 * Get the dependencies at [version] of the package being changed. 233 * Get the dependencies at [version] of the package being changed.
234 */ 234 */
235 Future<Map<String, PackageRef>> getDependencyRefs(VersionSolver solver, 235 Future<Map<String, PackageRef>> getDependencyRefs(VersionSolver solver,
236 Version version) { 236 Version version) {
237 // If there is no version, it means no package, so no dependencies. 237 // If there is no version, it means no package, so no dependencies.
238 if (version == null) { 238 if (version == null) {
239 return new Future<Map<String, PackageRef>>.immediate(<PackageRef>{}); 239 return
240 new Future<Map<String, PackageRef>>.immediate(<String, PackageRef>{});
240 } 241 }
241 242
242 var id = new PackageId(source, version, description); 243 var id = new PackageId(source, version, description);
243 return solver._pubspecs.load(id).transform((pubspec) { 244 return solver._pubspecs.load(id).transform((pubspec) {
244 var dependencies = <PackageRef>{}; 245 var dependencies = <String, PackageRef>{};
245 for (var dependency in pubspec.dependencies) { 246 for (var dependency in pubspec.dependencies) {
246 dependencies[dependency.name] = dependency; 247 dependencies[dependency.name] = dependency;
247 } 248 }
248 return dependencies; 249 return dependencies;
249 }); 250 });
250 } 251 }
251 } 252 }
252 253
253 /** 254 /**
254 * A constraint that a depending package places on a dependent package has 255 * A constraint that a depending package places on a dependent package has
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 * If no packages have a constraint on this one (which can happen when this 464 * If no packages have a constraint on this one (which can happen when this
464 * package is in the process of being added to the graph), returns `null`. 465 * package is in the process of being added to the graph), returns `null`.
465 */ 466 */
466 VersionConstraint get constraint() { 467 VersionConstraint get constraint() {
467 if (_refs.isEmpty()) return null; 468 if (_refs.isEmpty()) return null;
468 return new VersionConstraint.intersect( 469 return new VersionConstraint.intersect(
469 _refs.getValues().map((ref) => ref.constraint)); 470 _refs.getValues().map((ref) => ref.constraint));
470 } 471 }
471 472
472 Dependency(this.name) 473 Dependency(this.name)
473 : _refs = <PackageRef>{}; 474 : _refs = <String, PackageRef>{};
474 475
475 /** 476 /**
476 * Places [ref] as a constraint from [package] onto this. 477 * Places [ref] as a constraint from [package] onto this.
477 */ 478 */
478 void placeConstraint(String package, PackageRef ref) { 479 void placeConstraint(String package, PackageRef ref) {
479 // If this isn't the first constraint placed on this package, make sure it 480 // If this isn't the first constraint placed on this package, make sure it
480 // matches the source and description of past constraints. 481 // matches the source and description of past constraints.
481 if (_refs.isEmpty()) { 482 if (_refs.isEmpty()) {
482 source = ref.source; 483 source = ref.source;
483 description = ref.description; 484 description = ref.description;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 final description1; 573 final description1;
573 final description2; 574 final description2;
574 575
575 DescriptionMismatchException(this.package, this.description1, 576 DescriptionMismatchException(this.package, this.description1,
576 this.description2); 577 this.description2);
577 578
578 // TODO(nweiz): Dump to YAML when that's supported 579 // TODO(nweiz): Dump to YAML when that's supported
579 String toString() => "Package '$package' has conflicting descriptions " 580 String toString() => "Package '$package' has conflicting descriptions "
580 "'${JSON.stringify(description1)}' and '${JSON.stringify(description2)}'"; 581 "'${JSON.stringify(description1)}' and '${JSON.stringify(description2)}'";
581 } 582 }
OLDNEW
« no previous file with comments | « utils/pub/source_registry.dart ('k') | utils/pub/yaml/composer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698