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

Side by Side Diff: utils/pub/version.dart

Issue 10850034: Rename BadNumberFormatException -> FormatException. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « utils/pub/utils.dart ('k') | utils/tests/pub/lock_file_test.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /** 5 /**
6 * Handles version numbers, following the [Semantic Versioning][semver] spec. 6 * Handles version numbers, following the [Semantic Versioning][semver] spec.
7 * 7 *
8 * [semver]: http://semver.org/ 8 * [semver]: http://semver.org/
9 */ 9 */
10 #library('version'); 10 #library('version');
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 try { 61 try {
62 int major = Math.parseInt(match[1]); 62 int major = Math.parseInt(match[1]);
63 int minor = Math.parseInt(match[2]); 63 int minor = Math.parseInt(match[2]);
64 int patch = Math.parseInt(match[3]); 64 int patch = Math.parseInt(match[3]);
65 65
66 String preRelease = match[5]; 66 String preRelease = match[5];
67 String build = match[8]; 67 String build = match[8];
68 68
69 return new Version(major, minor, patch, preRelease, build); 69 return new Version(major, minor, patch, preRelease, build);
70 } catch (BadNumberFormatException ex) { 70 } catch (FormatException ex) {
71 throw new FormatException('Could not parse "$text".'); 71 throw new FormatException('Could not parse "$text".');
72 } 72 }
73 } 73 }
74 74
75 bool operator ==(other) { 75 bool operator ==(other) {
76 if (other is! Version) return false; 76 if (other is! Version) return false;
77 return compareTo(other) == 0; 77 return compareTo(other) == 0;
78 } 78 }
79 79
80 bool operator <(Version other) => compareTo(other) < 0; 80 bool operator <(Version other) => compareTo(other) < 0;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 } 174 }
175 175
176 /** 176 /**
177 * Splits a string of dot-delimited identifiers into their component parts. 177 * Splits a string of dot-delimited identifiers into their component parts.
178 * Identifiers that are numeric are converted to numbers. 178 * Identifiers that are numeric are converted to numbers.
179 */ 179 */
180 List _splitParts(String text) { 180 List _splitParts(String text) {
181 return text.split('.').map((part) { 181 return text.split('.').map((part) {
182 try { 182 try {
183 return Math.parseInt(part); 183 return Math.parseInt(part);
184 } catch (BadNumberFormatException ex) { 184 } catch (FormatException ex) {
185 // Not a number. 185 // Not a number.
186 return part; 186 return part;
187 } 187 }
188 }); 188 });
189 } 189 }
190 } 190 }
191 191
192 /** 192 /**
193 * A [VersionConstraint] is a predicate that can determine whether a given 193 * A [VersionConstraint] is a predicate that can determine whether a given
194 * version is valid or not. For example, a ">= 2.0.0" constraint allows any 194 * version is valid or not. For example, a ">= 2.0.0" constraint allows any
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 case '<': return new VersionRange(max: version, includeMax: false); 418 case '<': return new VersionRange(max: version, includeMax: false);
419 case '>=': return new VersionRange(min: version, includeMin: true); 419 case '>=': return new VersionRange(min: version, includeMin: true);
420 case '>': return new VersionRange(min: version, includeMin: false); 420 case '>': return new VersionRange(min: version, includeMin: false);
421 } 421 }
422 } 422 }
423 423
424 // Otherwise, it must be an explicit version. 424 // Otherwise, it must be an explicit version.
425 return new Version.parse(text); 425 return new Version.parse(text);
426 } 426 }
427 } 427 }
OLDNEW
« no previous file with comments | « utils/pub/utils.dart ('k') | utils/tests/pub/lock_file_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698