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

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

Issue 10399076: Get codebase ready for actually supporting versioning. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Validate descriptions and move stuff into Entrypoint. Created 8 years, 7 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
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 * Generic utility functions. Stuff that should possibly be in core. 6 * Generic utility functions. Stuff that should possibly be in core.
7 */ 7 */
8 #library('pub_utils'); 8 #library('pub_utils');
9 9
10 /** Thrown by methods that parse text when the text isn't a valid. */
11 class FormatException implements Exception {
12 final String message;
13
14 FormatException(this.message);
15
16 String toString() => message;
17 }
18
10 // TODO(rnystrom): Move into String? 19 // TODO(rnystrom): Move into String?
11 /** Pads [source] to [length] by adding spaces at the end. */ 20 /** Pads [source] to [length] by adding spaces at the end. */
12 String padRight(String source, int length) { 21 String padRight(String source, int length) {
13 final result = new StringBuffer(); 22 final result = new StringBuffer();
14 result.add(source); 23 result.add(source);
15 24
16 while (result.length < length) { 25 while (result.length < length) {
17 result.add(' '); 26 result.add(' ');
18 } 27 }
19 28
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 /** 63 /**
55 * Asserts that [iter] contains only one element, and returns it. 64 * Asserts that [iter] contains only one element, and returns it.
56 */ 65 */
57 only(Iterable iter) { 66 only(Iterable iter) {
58 var iterator = iter.iterator(); 67 var iterator = iter.iterator();
59 assert(iterator.hasNext()); 68 assert(iterator.hasNext());
60 var obj = iterator.next(); 69 var obj = iterator.next();
61 assert(!iterator.hasNext()); 70 assert(!iterator.hasNext());
62 return obj; 71 return obj;
63 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698