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

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

Issue 11442068: A few small changes to the "pub lish" confirmation UI. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix tests. Created 8 years 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 | « no previous file | utils/tests/pub/directory_tree_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 /// A simple library for rendering a list of files as a directory tree. 5 /// A simple library for rendering a list of files as a directory tree.
6 library directory_tree; 6 library directory_tree;
7 7
8 import 'log.dart' as log; 8 import 'log.dart' as log;
9 import 'path.dart' as path; 9 import 'path.dart' as path;
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 /// | |-- main.dart 43 /// | |-- main.dart
44 /// | '-- web copy 44 /// | '-- web copy
45 /// | '-- web_example.dart 45 /// | '-- web_example.dart
46 /// |-- lib 46 /// |-- lib
47 /// | '-- path.dart 47 /// | '-- path.dart
48 /// |-- pubspec.yaml 48 /// |-- pubspec.yaml
49 /// '-- test 49 /// '-- test
50 /// |-- absolute_test.dart 50 /// |-- absolute_test.dart
51 /// |-- all_test.dart 51 /// |-- all_test.dart
52 /// |-- basename_test.dart 52 /// |-- basename_test.dart
53 /// | (7 more...) 53 /// | (7 more...)
54 /// |-- path_windows_test.dart 54 /// |-- path_windows_test.dart
55 /// |-- relative_test.dart 55 /// |-- relative_test.dart
56 /// '-- split_test.dart 56 /// '-- split_test.dart
57 /// 57 ///
58 String generateTree(List<String> files) { 58 String generateTree(List<String> files) {
59 // Parse out the files into a tree of nested maps. 59 // Parse out the files into a tree of nested maps.
60 var root = {}; 60 var root = {};
61 for (var file in files) { 61 for (var file in files) {
62 var parts = path.split(file); 62 var parts = path.split(file);
63 var directory = root; 63 var directory = root;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 // Recurse to the children. 103 // Recurse to the children.
104 var childNames = new List.from(children.keys); 104 var childNames = new List.from(children.keys);
105 childNames.sort(); 105 childNames.sort();
106 106
107 _drawChild(bool isLastChild, String child) { 107 _drawChild(bool isLastChild, String child) {
108 var childPrefix = _getPrefix(name == null, isLast); 108 var childPrefix = _getPrefix(name == null, isLast);
109 _draw(buffer, '$prefix$childPrefix', isLastChild, child, children[child]); 109 _draw(buffer, '$prefix$childPrefix', isLastChild, child, children[child]);
110 } 110 }
111 111
112 if (childNames.length <= 10) { 112 if (name == null || childNames.length <= 10) {
113 // Not too many, so show all the children. 113 // Not too many, so show all the children.
114 for (var i = 0; i < childNames.length; i++) { 114 for (var i = 0; i < childNames.length; i++) {
115 _drawChild(i == childNames.length - 1, childNames[i]); 115 _drawChild(i == childNames.length - 1, childNames[i]);
116 } 116 }
117 } else { 117 } else {
118 // Show the first few. 118 // Show the first few.
119 _drawChild(false, childNames[0]); 119 _drawChild(false, childNames[0]);
120 _drawChild(false, childNames[1]); 120 _drawChild(false, childNames[1]);
121 _drawChild(false, childNames[2]); 121 _drawChild(false, childNames[2]);
122 122
123 // Elide the middle ones. 123 // Elide the middle ones.
124 buffer.add(prefix); 124 buffer.add(prefix);
125 buffer.add(_getPrefix(name == null, isLast)); 125 buffer.add(_getPrefix(name == null, isLast));
126 buffer.add('| (${childNames.length - 6} more...)\n'); 126 buffer.add('| (${childNames.length - 6} more...)\n');
127 127
128 // Show the last few. 128 // Show the last few.
129 _drawChild(false, childNames[childNames.length - 3]); 129 _drawChild(false, childNames[childNames.length - 3]);
130 _drawChild(false, childNames[childNames.length - 2]); 130 _drawChild(false, childNames[childNames.length - 2]);
131 _drawChild(true, childNames[childNames.length - 1]); 131 _drawChild(true, childNames[childNames.length - 1]);
132 } 132 }
133 } 133 }
OLDNEW
« no previous file with comments | « no previous file | utils/tests/pub/directory_tree_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698