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

Unified Diff: utils/pub/version.dart

Issue 12038038: Add support for specifying SDK version constraints in pubspecs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Clean up a bit. Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/pub/sdk_source.dart ('k') | utils/tests/pub/command_line_config.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/version.dart
diff --git a/utils/pub/version.dart b/utils/pub/version.dart
index e7ca3d1299f56551ec10768476f0ed0ddc40783b..18e15a5f84a8f7deabdb0cf35a4e26aff37e3708 100644
--- a/utils/pub/version.dart
+++ b/utils/pub/version.dart
@@ -110,7 +110,9 @@ class Version implements Comparable, VersionConstraint {
if (other is VersionRange) return other.intersect(this);
// Intersecting two versions only works if they are the same.
- if (other is Version) return this == other ? this : const _EmptyVersion();
+ if (other is Version) {
+ return this == other ? this : VersionConstraint.empty;
+ }
throw new ArgumentError(
'Unknown VersionConstraint type $other.');
@@ -206,8 +208,11 @@ class Version implements Comparable, VersionConstraint {
/// version that is "2.0.0" or greater. Version objects themselves implement
/// this to match a specific version.
abstract class VersionConstraint {
+ /// A [VersionConstraint] that allows all versions.
+ static VersionConstraint any = new VersionRange();
+
/// A [VersionConstraint] that allows no versions: i.e. the empty set.
- factory VersionConstraint.empty() => const _EmptyVersion();
+ static VersionConstraint empty = const _EmptyVersion();
/// Parses a version constraint. This string is a space-separated series of
/// version parts. Each part can be one of:
@@ -333,7 +338,9 @@ class VersionRange implements VersionConstraint {
if (other.isEmpty) return other;
// A range and a Version just yields the version if it's in the range.
- if (other is Version) return allows(other) ? other : const _EmptyVersion();
+ if (other is Version) {
+ return allows(other) ? other : VersionConstraint.empty;
+ }
if (other is VersionRange) {
// Intersect the two ranges.
@@ -373,13 +380,13 @@ class VersionRange implements VersionConstraint {
if (intersectIncludeMin && intersectIncludeMax) return intersectMin;
// Otherwise, no versions.
- return const _EmptyVersion();
+ return VersionConstraint.empty;
}
if (intersectMin != null && intersectMax != null &&
intersectMin > intersectMax) {
// Non-overlapping ranges, so empty.
- return const _EmptyVersion();
+ return VersionConstraint.empty;
}
// If we got here, there is an actual range.
« no previous file with comments | « utils/pub/sdk_source.dart ('k') | utils/tests/pub/command_line_config.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698