@@ -53,8 +53,8 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
53
53
///
54
54
/// If [includeMin] is `true` , then the minimum end of the range is inclusive.
55
55
/// Likewise, passing [includeMax] as `true` makes the upper end inclusive.
56
- VersionRange ({ this .min, this .max,
57
- this .includeMin: false , this .includeMax: false }) {
56
+ VersionRange (
57
+ { this .min, this .max, this .includeMin: false , this .includeMax: false }) {
58
58
if (min != null && max != null && min > max) {
59
59
throw new ArgumentError (
60
60
'Minimum version ("$min ") must be less than maximum ("$max ").' );
@@ -65,13 +65,16 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
65
65
if (other is ! VersionRange ) return false ;
66
66
67
67
return min == other.min &&
68
- max == other.max &&
69
- includeMin == other.includeMin &&
70
- includeMax == other.includeMax;
68
+ max == other.max &&
69
+ includeMin == other.includeMin &&
70
+ includeMax == other.includeMax;
71
71
}
72
72
73
- int get hashCode => min.hashCode ^ (max.hashCode * 3 ) ^
74
- (includeMin.hashCode * 5 ) ^ (includeMax.hashCode * 7 );
73
+ int get hashCode =>
74
+ min.hashCode ^
75
+ (max.hashCode * 3 ) ^
76
+ (includeMin.hashCode * 5 ) ^
77
+ (includeMax.hashCode * 7 );
75
78
76
79
bool get isEmpty => false ;
77
80
@@ -88,7 +91,6 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
88
91
if (other > max) return false ;
89
92
if (! includeMax && other == max) return false ;
90
93
91
-
92
94
// Disallow pre-release versions that have the same major, minor, and
93
95
// patch version as the max, but only if neither the max nor the min is a
94
96
// pre-release of that version. This ensures that "^1.2.3" doesn't include
@@ -109,9 +111,11 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
109
111
// ">1.2.3" can still match prerelease versions if they're the only things
110
112
// available.
111
113
var maxIsReleaseOfOther = ! includeMax &&
112
- ! max.isPreRelease && other.isPreRelease &&
114
+ ! max.isPreRelease &&
115
+ other.isPreRelease &&
113
116
_equalsWithoutPreRelease (other, max);
114
- var minIsPreReleaseOfOther = min != null && min.isPreRelease &&
117
+ var minIsPreReleaseOfOther = min != null &&
118
+ min.isPreRelease &&
115
119
_equalsWithoutPreRelease (other, min);
116
120
if (maxIsReleaseOfOther && ! minIsPreReleaseOfOther) return false ;
117
121
}
@@ -121,8 +125,8 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
121
125
122
126
bool _equalsWithoutPreRelease (Version version1, Version version2) =>
123
127
version1.major == version2.major &&
124
- version1.minor == version2.minor &&
125
- version1.patch == version2.patch;
128
+ version1.minor == version2.minor &&
129
+ version1.patch == version2.patch;
126
130
127
131
bool allowsAll (VersionConstraint other) {
128
132
if (other.isEmpty) return true ;
@@ -216,15 +220,19 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
216
220
return VersionConstraint .empty;
217
221
}
218
222
219
- if (intersectMin != null && intersectMax != null &&
223
+ if (intersectMin != null &&
224
+ intersectMax != null &&
220
225
intersectMin > intersectMax) {
221
226
// Non-overlapping ranges, so empty.
222
227
return VersionConstraint .empty;
223
228
}
224
229
225
230
// If we got here, there is an actual range.
226
- return new VersionRange (min: intersectMin, max: intersectMax,
227
- includeMin: intersectIncludeMin, includeMax: intersectIncludeMax);
231
+ return new VersionRange (
232
+ min: intersectMin,
233
+ max: intersectMax,
234
+ includeMin: intersectIncludeMin,
235
+ includeMax: intersectIncludeMax);
228
236
}
229
237
230
238
throw new ArgumentError ('Unknown VersionConstraint type $other .' );
@@ -236,14 +244,18 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
236
244
237
245
if (other == min) {
238
246
return new VersionRange (
239
- min: this .min, max: this .max,
240
- includeMin: true , includeMax: this .includeMax);
247
+ min: this .min,
248
+ max: this .max,
249
+ includeMin: true ,
250
+ includeMax: this .includeMax);
241
251
}
242
252
243
253
if (other == max) {
244
254
return new VersionRange (
245
- min: this .min, max: this .max,
246
- includeMin: this .includeMin, includeMax: true );
255
+ min: this .min,
256
+ max: this .max,
257
+ includeMin: this .includeMin,
258
+ includeMax: true );
247
259
}
248
260
249
261
return new VersionConstraint .unionOf ([this , other]);
@@ -283,8 +295,11 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
283
295
unionIncludeMax = true ;
284
296
}
285
297
286
- return new VersionRange (min: unionMin, max: unionMax,
287
- includeMin: unionIncludeMin, includeMax: unionIncludeMax);
298
+ return new VersionRange (
299
+ min: unionMin,
300
+ max: unionMax,
301
+ includeMin: unionIncludeMin,
302
+ includeMax: unionIncludeMax);
288
303
}
289
304
290
305
return new VersionConstraint .unionOf ([this , other]);
@@ -299,24 +314,20 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
299
314
if (other == min) {
300
315
if (! includeMin) return this ;
301
316
return new VersionRange (
302
- min: min, max: max,
303
- includeMin: false , includeMax: includeMax);
317
+ min: min, max: max, includeMin: false , includeMax: includeMax);
304
318
}
305
319
306
320
if (other == max) {
307
321
if (! includeMax) return this ;
308
322
return new VersionRange (
309
- min: min, max: max,
310
- includeMin: includeMin, includeMax: false );
323
+ min: min, max: max, includeMin: includeMin, includeMax: false );
311
324
}
312
325
313
326
return new VersionUnion .fromRanges ([
314
327
new VersionRange (
315
- min: min, max: other,
316
- includeMin: includeMin, includeMax: false ),
328
+ min: min, max: other, includeMin: includeMin, includeMax: false ),
317
329
new VersionRange (
318
- min: other, max: max,
319
- includeMin: false , includeMax: includeMax)
330
+ min: other, max: max, includeMin: false , includeMax: includeMax)
320
331
]);
321
332
} else if (other is VersionRange ) {
322
333
if (! allowsAny (other)) return this ;
@@ -330,8 +341,10 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
330
341
before = min;
331
342
} else {
332
343
before = new VersionRange (
333
- min: min, max: other.min,
334
- includeMin: includeMin, includeMax: ! other.includeMin);
344
+ min: min,
345
+ max: other.min,
346
+ includeMin: includeMin,
347
+ includeMax: ! other.includeMin);
335
348
}
336
349
337
350
VersionRange after;
@@ -343,8 +356,10 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
343
356
after = max;
344
357
} else {
345
358
after = new VersionRange (
346
- min: other.max, max: max,
347
- includeMin: ! other.includeMax, includeMax: includeMax);
359
+ min: other.max,
360
+ max: max,
361
+ includeMin: ! other.includeMax,
362
+ includeMax: includeMax);
348
363
}
349
364
350
365
if (before == null && after == null ) return VersionConstraint .empty;
0 commit comments