Skip to content

Commit d32228c

Browse files
committed
dartfmt
1 parent ecc6248 commit d32228c

10 files changed

+554
-453
lines changed

lib/src/patterns.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
/// Regex that matches a version number at the beginning of a string.
6-
final START_VERSION = new RegExp(
7-
r'^' // Start at beginning.
8-
r'(\d+).(\d+).(\d+)' // Version number.
9-
r'(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?' // Pre-release.
6+
final START_VERSION = new RegExp(r'^' // Start at beginning.
7+
r'(\d+).(\d+).(\d+)' // Version number.
8+
r'(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?' // Pre-release.
109
r'(\+([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?'); // Build.
1110

1211
/// Like [START_VERSION] but matches the entire string.

lib/src/version.dart

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ class Version implements VersionConstraint, VersionRange {
8989
bool get includeMax => true;
9090

9191
Version._(this.major, this.minor, this.patch, String preRelease, String build,
92-
this._text)
92+
this._text)
9393
: preRelease = preRelease == null ? [] : _splitParts(preRelease),
9494
build = build == null ? [] : _splitParts(build) {
95-
if (major < 0) throw new ArgumentError(
96-
'Major version must be non-negative.');
97-
if (minor < 0) throw new ArgumentError(
98-
'Minor version must be non-negative.');
99-
if (patch < 0) throw new ArgumentError(
100-
'Patch version must be non-negative.');
95+
if (major < 0)
96+
throw new ArgumentError('Major version must be non-negative.');
97+
if (minor < 0)
98+
throw new ArgumentError('Minor version must be non-negative.');
99+
if (patch < 0)
100+
throw new ArgumentError('Patch version must be non-negative.');
101101
}
102102

103103
/// Creates a new [Version] object.
@@ -137,7 +137,8 @@ class Version implements VersionConstraint, VersionRange {
137137
static Version primary(List<Version> versions) {
138138
var primary;
139139
for (var version in versions) {
140-
if (primary == null || (!version.isPreRelease && primary.isPreRelease) ||
140+
if (primary == null ||
141+
(!version.isPreRelease && primary.isPreRelease) ||
141142
(version.isPreRelease == primary.isPreRelease && version > primary)) {
142143
primary = version;
143144
}
@@ -161,13 +162,18 @@ class Version implements VersionConstraint, VersionRange {
161162

162163
bool operator ==(other) {
163164
if (other is! Version) return false;
164-
return major == other.major && minor == other.minor &&
165+
return major == other.major &&
166+
minor == other.minor &&
165167
patch == other.patch &&
166168
_equality.equals(preRelease, other.preRelease) &&
167169
_equality.equals(build, other.build);
168170
}
169171

170-
int get hashCode => major ^ minor ^ patch ^ _equality.hash(preRelease) ^
172+
int get hashCode =>
173+
major ^
174+
minor ^
175+
patch ^
176+
_equality.hash(preRelease) ^
171177
_equality.hash(build);
172178

173179
bool operator <(Version other) => compareTo(other) < 0;
@@ -253,14 +259,18 @@ class Version implements VersionConstraint, VersionRange {
253259
if (other is VersionRange) {
254260
if (other.min == this) {
255261
return new VersionRange(
256-
min: other.min, max: other.max,
257-
includeMin: true, includeMax: other.includeMax);
262+
min: other.min,
263+
max: other.max,
264+
includeMin: true,
265+
includeMax: other.includeMax);
258266
}
259267

260268
if (other.max == this) {
261269
return new VersionRange(
262-
min: other.min, max: other.max,
263-
includeMin: other.includeMin, includeMax: true);
270+
min: other.min,
271+
max: other.max,
272+
includeMin: other.includeMin,
273+
includeMax: true);
264274
}
265275
}
266276

lib/src/version_constraint.dart

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,14 @@ abstract class VersionConstraint {
8181
}
8282

8383
switch (op) {
84-
case '<=': return new VersionRange(max: version, includeMax: true);
85-
case '<': return new VersionRange(max: version, includeMax: false);
86-
case '>=': return new VersionRange(min: version, includeMin: true);
87-
case '>': return new VersionRange(min: version, includeMin: false);
84+
case '<=':
85+
return new VersionRange(max: version, includeMax: true);
86+
case '<':
87+
return new VersionRange(max: version, includeMax: false);
88+
case '>=':
89+
return new VersionRange(min: version, includeMin: true);
90+
case '>':
91+
return new VersionRange(min: version, includeMin: false);
8892
}
8993
throw "Unreachable.";
9094
}
@@ -172,8 +176,7 @@ abstract class VersionConstraint {
172176
///
173177
/// It allows any versions that any of those constraints allows. If
174178
/// [constraints] is empty, this returns a constraint that allows no versions.
175-
factory VersionConstraint.unionOf(
176-
Iterable<VersionConstraint> constraints) {
179+
factory VersionConstraint.unionOf(Iterable<VersionConstraint> constraints) {
177180
var flattened = constraints.expand((constraint) {
178181
if (constraint.isEmpty) return [];
179182
if (constraint is VersionUnion) return constraint.ranges;
@@ -257,9 +260,12 @@ class _EmptyVersion implements VersionConstraint {
257260
}
258261

259262
class _CompatibleWithVersionRange extends VersionRange {
260-
_CompatibleWithVersionRange(Version version) : super(
261-
min: version, includeMin: true,
262-
max: version.nextBreaking, includeMax: false);
263+
_CompatibleWithVersionRange(Version version)
264+
: super(
265+
min: version,
266+
includeMin: true,
267+
max: version.nextBreaking,
268+
includeMax: false);
263269

264270
String toString() => '^$min';
265271
}

lib/src/version_range.dart

Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
5353
///
5454
/// If [includeMin] is `true`, then the minimum end of the range is inclusive.
5555
/// 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}) {
5858
if (min != null && max != null && min > max) {
5959
throw new ArgumentError(
6060
'Minimum version ("$min") must be less than maximum ("$max").');
@@ -65,13 +65,16 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
6565
if (other is! VersionRange) return false;
6666

6767
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;
7171
}
7272

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);
7578

7679
bool get isEmpty => false;
7780

@@ -88,7 +91,6 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
8891
if (other > max) return false;
8992
if (!includeMax && other == max) return false;
9093

91-
9294
// Disallow pre-release versions that have the same major, minor, and
9395
// patch version as the max, but only if neither the max nor the min is a
9496
// pre-release of that version. This ensures that "^1.2.3" doesn't include
@@ -109,9 +111,11 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
109111
// ">1.2.3" can still match prerelease versions if they're the only things
110112
// available.
111113
var maxIsReleaseOfOther = !includeMax &&
112-
!max.isPreRelease && other.isPreRelease &&
114+
!max.isPreRelease &&
115+
other.isPreRelease &&
113116
_equalsWithoutPreRelease(other, max);
114-
var minIsPreReleaseOfOther = min != null && min.isPreRelease &&
117+
var minIsPreReleaseOfOther = min != null &&
118+
min.isPreRelease &&
115119
_equalsWithoutPreRelease(other, min);
116120
if (maxIsReleaseOfOther && !minIsPreReleaseOfOther) return false;
117121
}
@@ -121,8 +125,8 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
121125

122126
bool _equalsWithoutPreRelease(Version version1, Version version2) =>
123127
version1.major == version2.major &&
124-
version1.minor == version2.minor &&
125-
version1.patch == version2.patch;
128+
version1.minor == version2.minor &&
129+
version1.patch == version2.patch;
126130

127131
bool allowsAll(VersionConstraint other) {
128132
if (other.isEmpty) return true;
@@ -216,15 +220,19 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
216220
return VersionConstraint.empty;
217221
}
218222

219-
if (intersectMin != null && intersectMax != null &&
223+
if (intersectMin != null &&
224+
intersectMax != null &&
220225
intersectMin > intersectMax) {
221226
// Non-overlapping ranges, so empty.
222227
return VersionConstraint.empty;
223228
}
224229

225230
// 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);
228236
}
229237

230238
throw new ArgumentError('Unknown VersionConstraint type $other.');
@@ -236,14 +244,18 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
236244

237245
if (other == min) {
238246
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);
241251
}
242252

243253
if (other == max) {
244254
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);
247259
}
248260

249261
return new VersionConstraint.unionOf([this, other]);
@@ -283,8 +295,11 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
283295
unionIncludeMax = true;
284296
}
285297

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);
288303
}
289304

290305
return new VersionConstraint.unionOf([this, other]);
@@ -299,24 +314,20 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
299314
if (other == min) {
300315
if (!includeMin) return this;
301316
return new VersionRange(
302-
min: min, max: max,
303-
includeMin: false, includeMax: includeMax);
317+
min: min, max: max, includeMin: false, includeMax: includeMax);
304318
}
305319

306320
if (other == max) {
307321
if (!includeMax) return this;
308322
return new VersionRange(
309-
min: min, max: max,
310-
includeMin: includeMin, includeMax: false);
323+
min: min, max: max, includeMin: includeMin, includeMax: false);
311324
}
312325

313326
return new VersionUnion.fromRanges([
314327
new VersionRange(
315-
min: min, max: other,
316-
includeMin: includeMin, includeMax: false),
328+
min: min, max: other, includeMin: includeMin, includeMax: false),
317329
new VersionRange(
318-
min: other, max: max,
319-
includeMin: false, includeMax: includeMax)
330+
min: other, max: max, includeMin: false, includeMax: includeMax)
320331
]);
321332
} else if (other is VersionRange) {
322333
if (!allowsAny(other)) return this;
@@ -330,8 +341,10 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
330341
before = min;
331342
} else {
332343
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);
335348
}
336349

337350
VersionRange after;
@@ -343,8 +356,10 @@ class VersionRange implements Comparable<VersionRange>, VersionConstraint {
343356
after = max;
344357
} else {
345358
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);
348363
}
349364

350365
if (before == null && after == null) return VersionConstraint.empty;

lib/src/version_union.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ class VersionUnion implements VersionConstraint {
9696
ourRanges.moveNext();
9797
theirRanges.moveNext();
9898
while (ourRanges.current != null && theirRanges.current != null) {
99-
var intersection = ourRanges.current
100-
.intersect(theirRanges.current);
99+
var intersection = ourRanges.current.intersect(theirRanges.current);
101100

102101
if (!intersection.isEmpty) newRanges.add(intersection);
103102

0 commit comments

Comments
 (0)