OLD | NEW |
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 'dart:math' as math; | 5 import 'dart:math' as math; |
6 | 6 |
7 import 'package:collection/collection.dart'; | 7 import 'package:collection/collection.dart'; |
8 | 8 |
9 import 'patterns.dart'; | 9 import 'patterns.dart'; |
10 import 'version_constraint.dart'; | 10 import 'version_constraint.dart'; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 if (other.max == this) { | 260 if (other.max == this) { |
261 return new VersionRange( | 261 return new VersionRange( |
262 min: other.min, max: other.max, | 262 min: other.min, max: other.max, |
263 includeMin: other.includeMin, includeMax: true); | 263 includeMin: other.includeMin, includeMax: true); |
264 } | 264 } |
265 } | 265 } |
266 | 266 |
267 return new VersionConstraint.unionOf([this, other]); | 267 return new VersionConstraint.unionOf([this, other]); |
268 } | 268 } |
269 | 269 |
| 270 VersionConstraint difference(VersionConstraint other) => |
| 271 other.allows(this) ? VersionConstraint.empty : this; |
| 272 |
270 int compareTo(VersionRange other) { | 273 int compareTo(VersionRange other) { |
271 if (other is Version) { | 274 if (other is Version) { |
272 if (major != other.major) return major.compareTo(other.major); | 275 if (major != other.major) return major.compareTo(other.major); |
273 if (minor != other.minor) return minor.compareTo(other.minor); | 276 if (minor != other.minor) return minor.compareTo(other.minor); |
274 if (patch != other.patch) return patch.compareTo(other.patch); | 277 if (patch != other.patch) return patch.compareTo(other.patch); |
275 | 278 |
276 // Pre-releases always come before no pre-release string. | 279 // Pre-releases always come before no pre-release string. |
277 if (!isPreRelease && other.isPreRelease) return 1; | 280 if (!isPreRelease && other.isPreRelease) return 1; |
278 if (!other.isPreRelease && isPreRelease) return -1; | 281 if (!other.isPreRelease && isPreRelease) return -1; |
279 | 282 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 // Compare two strings. | 325 // Compare two strings. |
323 return aPart.compareTo(bPart); | 326 return aPart.compareTo(bPart); |
324 } | 327 } |
325 } | 328 } |
326 } | 329 } |
327 | 330 |
328 // The lists are entirely equal. | 331 // The lists are entirely equal. |
329 return 0; | 332 return 0; |
330 } | 333 } |
331 } | 334 } |
OLD | NEW |