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

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

Issue 2029263003: Make the VersionUnion class public. (Closed) Base URL: git@github.com:dart-lang/pub_semver@master
Patch Set: Created 4 years, 6 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/version_constraint.dart ('k') | lib/src/version_union.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 'version.dart'; 5 import 'version.dart';
6 import 'version_constraint.dart'; 6 import 'version_constraint.dart';
7 import 'version_union.dart'; 7 import 'version_union.dart';
8 8
9 /// Constrains versions to a fall within a given range. 9 /// Constrains versions to a fall within a given range.
10 /// 10 ///
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 bool _equalsWithoutPreRelease(Version version1, Version version2) => 117 bool _equalsWithoutPreRelease(Version version1, Version version2) =>
118 version1.major == version2.major && 118 version1.major == version2.major &&
119 version1.minor == version2.minor && 119 version1.minor == version2.minor &&
120 version1.patch == version2.patch; 120 version1.patch == version2.patch;
121 121
122 bool allowsAll(VersionConstraint other) { 122 bool allowsAll(VersionConstraint other) {
123 if (other.isEmpty) return true; 123 if (other.isEmpty) return true;
124 if (other is Version) return allows(other); 124 if (other is Version) return allows(other);
125 125
126 if (other is VersionUnion) { 126 if (other is VersionUnion) {
127 return other.constraints.every((constraint) => allowsAll(constraint)); 127 return other.ranges.every((constraint) => allowsAll(constraint));
128 } 128 }
129 129
130 if (other is VersionRange) { 130 if (other is VersionRange) {
131 if (min != null) { 131 if (min != null) {
132 if (other.min == null) return false; 132 if (other.min == null) return false;
133 if (min > other.min) return false; 133 if (min > other.min) return false;
134 if (min == other.min && !includeMin && other.includeMin) return false; 134 if (min == other.min && !includeMin && other.includeMin) return false;
135 } 135 }
136 136
137 if (max != null) { 137 if (max != null) {
138 if (other.max == null) return false; 138 if (other.max == null) return false;
139 if (max < other.max) return false; 139 if (max < other.max) return false;
140 if (max == other.max && !includeMax && other.includeMax) return false; 140 if (max == other.max && !includeMax && other.includeMax) return false;
141 } 141 }
142 142
143 return true; 143 return true;
144 } 144 }
145 145
146 throw new ArgumentError('Unknown VersionConstraint type $other.'); 146 throw new ArgumentError('Unknown VersionConstraint type $other.');
147 } 147 }
148 148
149 bool allowsAny(VersionConstraint other) { 149 bool allowsAny(VersionConstraint other) {
150 if (other.isEmpty) return false; 150 if (other.isEmpty) return false;
151 if (other is Version) return allows(other); 151 if (other is Version) return allows(other);
152 152
153 if (other is VersionUnion) { 153 if (other is VersionUnion) {
154 return other.constraints.any((constraint) => allowsAny(constraint)); 154 return other.ranges.any((constraint) => allowsAny(constraint));
155 } 155 }
156 156
157 if (other is VersionRange) { 157 if (other is VersionRange) {
158 // If neither range has a minimum, they'll overlap at some point. 158 // If neither range has a minimum, they'll overlap at some point.
159 // 159 //
160 // ... this ] 160 // ... this ]
161 // ... other ] 161 // ... other ]
162 if (min == null && other.min == null) return true; 162 if (min == null && other.min == null) return true;
163 163
164 // If this range has a lower minimum than the other range, it overlaps as 164 // If this range has a lower minimum than the other range, it overlaps as
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 if (max != null) { 326 if (max != null) {
327 if (min != null) buffer.write(' '); 327 if (min != null) buffer.write(' ');
328 buffer.write(includeMax ? '<=' : '<'); 328 buffer.write(includeMax ? '<=' : '<');
329 buffer.write(max); 329 buffer.write(max);
330 } 330 }
331 331
332 if (min == null && max == null) buffer.write('any'); 332 if (min == null && max == null) buffer.write('any');
333 return buffer.toString(); 333 return buffer.toString();
334 } 334 }
335 } 335 }
OLDNEW
« no previous file with comments | « lib/src/version_constraint.dart ('k') | lib/src/version_union.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698