OLD | NEW |
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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 final description; | 246 final description; |
247 | 247 |
248 /** | 248 /** |
249 * The new selected version. | 249 * The new selected version. |
250 */ | 250 */ |
251 final Version version; | 251 final Version version; |
252 | 252 |
253 /** | 253 /** |
254 * The name of the package whose version is changing. | 254 * The name of the package whose version is changing. |
255 */ | 255 */ |
256 String get package() => source.packageName(description); | 256 String get package => source.packageName(description); |
257 | 257 |
258 ChangeVersion(this.source, this.description, this.version) { | 258 ChangeVersion(this.source, this.description, this.version) { |
259 if (source == null) throw "null source"; | 259 if (source == null) throw "null source"; |
260 } | 260 } |
261 | 261 |
262 Future process(VersionSolver solver) { | 262 Future process(VersionSolver solver) { |
263 var dependency = solver.getDependency(package); | 263 var dependency = solver.getDependency(package); |
264 var oldVersion = dependency.version; | 264 var oldVersion = dependency.version; |
265 solver.setVersion(package, version); | 265 solver.setVersion(package, version); |
266 | 266 |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 /** | 546 /** |
547 * Whether this dependency should always select the latest version. | 547 * Whether this dependency should always select the latest version. |
548 */ | 548 */ |
549 bool useLatestVersion = false; | 549 bool useLatestVersion = false; |
550 | 550 |
551 /** | 551 /** |
552 * Gets whether or not any other packages are currently depending on this | 552 * Gets whether or not any other packages are currently depending on this |
553 * one. If `false`, then it means this package is not part of the dependency | 553 * one. If `false`, then it means this package is not part of the dependency |
554 * graph and should be omitted. | 554 * graph and should be omitted. |
555 */ | 555 */ |
556 bool get isDependedOn() => !_refs.isEmpty(); | 556 bool get isDependedOn => !_refs.isEmpty(); |
557 | 557 |
558 /** The names of all the packages that depend on this dependency. */ | 558 /** The names of all the packages that depend on this dependency. */ |
559 Collection<String> get dependers() => _refs.getKeys(); | 559 Collection<String> get dependers => _refs.getKeys(); |
560 | 560 |
561 /** | 561 /** |
562 * Gets the overall constraint that all packages are placing on this one. | 562 * Gets the overall constraint that all packages are placing on this one. |
563 * If no packages have a constraint on this one (which can happen when this | 563 * If no packages have a constraint on this one (which can happen when this |
564 * package is in the process of being added to the graph), returns `null`. | 564 * package is in the process of being added to the graph), returns `null`. |
565 */ | 565 */ |
566 VersionConstraint get constraint() { | 566 VersionConstraint get constraint { |
567 if (_refs.isEmpty()) return null; | 567 if (_refs.isEmpty()) return null; |
568 return new VersionConstraint.intersect( | 568 return new VersionConstraint.intersect( |
569 _refs.getValues().map((ref) => ref.constraint)); | 569 _refs.getValues().map((ref) => ref.constraint)); |
570 } | 570 } |
571 | 571 |
572 Dependency(this.name) | 572 Dependency(this.name) |
573 : _refs = <String, PackageRef>{}; | 573 : _refs = <String, PackageRef>{}; |
574 | 574 |
575 Dependency._clone(Dependency other) | 575 Dependency._clone(Dependency other) |
576 : name = other.name, | 576 : name = other.name, |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 final description1; | 700 final description1; |
701 final description2; | 701 final description2; |
702 | 702 |
703 DescriptionMismatchException(this.package, this.description1, | 703 DescriptionMismatchException(this.package, this.description1, |
704 this.description2); | 704 this.description2); |
705 | 705 |
706 // TODO(nweiz): Dump to YAML when that's supported | 706 // TODO(nweiz): Dump to YAML when that's supported |
707 String toString() => "Package '$package' has conflicting descriptions " | 707 String toString() => "Package '$package' has conflicting descriptions " |
708 "'${JSON.stringify(description1)}' and '${JSON.stringify(description2)}'"; | 708 "'${JSON.stringify(description1)}' and '${JSON.stringify(description2)}'"; |
709 } | 709 } |
OLD | NEW |