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

Side by Side Diff: lib/dartdoc/utils.dart

Issue 10823257: Refactored accessors in mirrors from methods to properties. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Missing updates 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 | « lib/dartdoc/mirrors/mirrors_util.dart ('k') | tests/compiler/dart2js/mirrors_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 // Generic utility functions. 5 // Generic utility functions.
6 6
7 /** Turns [name] into something that's safe to use as a file name. */ 7 /** Turns [name] into something that's safe to use as a file name. */
8 String sanitize(String name) => name.replaceAll(':', '_').replaceAll('/', '_'); 8 String sanitize(String name) => name.replaceAll(':', '_').replaceAll('/', '_');
9 9
10 /** Returns the number of times [search] occurs in [text]. */ 10 /** Returns the number of times [search] occurs in [text]. */
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 if (text[start] != ' ') break; 43 if (text[start] != ' ') break;
44 } 44 }
45 45
46 return text.substring(start); 46 return text.substring(start);
47 } 47 }
48 48
49 /** Sorts the map by the key, doing a case-insensitive comparison. */ 49 /** Sorts the map by the key, doing a case-insensitive comparison. */
50 List<Mirror> orderByName(Collection<Mirror> list) { 50 List<Mirror> orderByName(Collection<Mirror> list) {
51 final elements = new List<Mirror>.from(list); 51 final elements = new List<Mirror>.from(list);
52 elements.sort((a,b) { 52 elements.sort((a,b) {
53 String aName = a.simpleName(); 53 String aName = a.simpleName;
54 String bName = b.simpleName(); 54 String bName = b.simpleName;
55 bool doma = aName.startsWith(@"$dom"); 55 bool doma = aName.startsWith(@"$dom");
56 bool domb = bName.startsWith(@"$dom"); 56 bool domb = bName.startsWith(@"$dom");
57 return doma == domb ? aName.compareTo(bName) : doma ? 1 : -1; 57 return doma == domb ? aName.compareTo(bName) : doma ? 1 : -1;
58 }); 58 });
59 return elements; 59 return elements;
60 } 60 }
61 61
62 /** 62 /**
63 * Joins [items] into a single, comma-separated string using [conjunction]. 63 * Joins [items] into a single, comma-separated string using [conjunction].
64 * E.g. `['A', 'B', 'C']` becomes `"A, B, and C"`. 64 * E.g. `['A', 'B', 'C']` becomes `"A, B, and C"`.
65 */ 65 */
66 String joinWithCommas(List<String> items, [String conjunction = 'and']) { 66 String joinWithCommas(List<String> items, [String conjunction = 'and']) {
67 if (items.length == 1) return items[0]; 67 if (items.length == 1) return items[0];
68 if (items.length == 2) return "${items[0]} $conjunction ${items[1]}"; 68 if (items.length == 2) return "${items[0]} $conjunction ${items[1]}";
69 return '${Strings.join(items.getRange(0, items.length - 1), ', ')}' 69 return '${Strings.join(items.getRange(0, items.length - 1), ', ')}'
70 ', $conjunction ${items[items.length - 1]}'; 70 ', $conjunction ${items[items.length - 1]}';
71 } 71 }
72 72
73 void writeString(File file, String text) { 73 void writeString(File file, String text) {
74 var randomAccessFile = file.openSync(FileMode.WRITE); 74 var randomAccessFile = file.openSync(FileMode.WRITE);
75 randomAccessFile.writeStringSync(text); 75 randomAccessFile.writeStringSync(text);
76 randomAccessFile.closeSync(); 76 randomAccessFile.closeSync();
77 } 77 }
OLDNEW
« no previous file with comments | « lib/dartdoc/mirrors/mirrors_util.dart ('k') | tests/compiler/dart2js/mirrors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698