Chromium Code Reviews| Index: lib/dartdoc/utils.dart |
| diff --git a/lib/dartdoc/utils.dart b/lib/dartdoc/utils.dart |
| index b2e5758375bb9ca3feb3b83d7bbd78b94813220b..45df37854c77b1d641e119c5ee325052b59d6004 100644 |
| --- a/lib/dartdoc/utils.dart |
| +++ b/lib/dartdoc/utils.dart |
| @@ -47,20 +47,20 @@ String unindent(String text, int indentation) { |
| } |
| /** Sorts the map by the key, doing a case-insensitive comparison. */ |
| -List orderByName(Map<String, Dynamic> map) { |
| - List keys = map.getKeys(); |
| - keys.sort((a, b) { |
| +List orderByName(List list) { |
|
Lasse Reichstein Nielsen
2012/07/09 10:39:33
Put a generic type on the List types here. It's pa
Johnni Winther
2012/07/09 14:57:18
Done.
|
| + final elements = []; |
| + for (var element in list) { |
| + elements.add(element); |
| + } |
|
Lasse Reichstein Nielsen
2012/07/09 10:39:33
final elements = new List<whateveritis>.from(list)
Johnni Winther
2012/07/09 14:57:18
Done.
|
| + elements.sort((a, b) { |
| // Hack: make sure $dom methods show up last in the list not first. |
| String transformName(String name) => |
| name.toUpperCase().replaceFirst(const RegExp('\\\$DOM_'), 'zzzz'); |
|
Lasse Reichstein Nielsen
2012/07/09 10:39:33
Use raw strings for regexp literals: const RegExp(
Johnni Winther
2012/07/09 14:57:18
Done.
|
| - return transformName(a).compareTo(transformName(b)); |
| + return transformName(a.simpleName()).compareTo( |
|
kasperl
2012/07/06 12:40:41
Maybe do the transform before calling compareTo an
Johnni Winther
2012/07/09 14:57:18
Done.
|
| + transformName(b.simpleName())); |
| }); |
| - final values = []; |
| - for (var k in keys) { |
| - values.add(map[k]); |
| - } |
| - return values; |
| + return elements; |
| } |
| /** |
| @@ -70,6 +70,12 @@ List orderByName(Map<String, Dynamic> map) { |
| String joinWithCommas(List<String> items, [String conjunction = 'and']) { |
| if (items.length == 1) return items[0]; |
| if (items.length == 2) return "${items[0]} $conjunction ${items[1]}"; |
| - return Strings.join(items.getRange(0, items.length - 1), ', ') + |
| - ', $conjunction ' + items[items.length - 1]; |
| + return '${Strings.join(items.getRange(0, items.length - 1), ', ')}' |
| + ', $conjunction ${items[items.length - 1]}'; |
| +} |
| + |
| +void writeString(File file, String text) { |
| + var randomAccessFile = file.openSync(FileMode.WRITE); |
| + randomAccessFile.writeStringSync(text); |
| + randomAccessFile.closeSync(); |
| } |