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

Side by Side Diff: tools/testing/dart/vendored_pkg/args/src/usage.dart

Issue 2903703002: Tighten types in test.dart even more. (Closed)
Patch Set: Play nicer with strong mode. Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library args.src.usage; 5 library args.src.usage;
6 6
7 import 'dart:math'; 7 import 'dart:math';
8 8
9 import '../args.dart'; 9 import '../args.dart';
10 10
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 title = max(title, getAllowedTitle(allowed).length); 137 title = max(title, getAllowedTitle(allowed).length);
138 } 138 }
139 } 139 }
140 }); 140 });
141 141
142 // Leave a gutter between the columns. 142 // Leave a gutter between the columns.
143 title += 4; 143 title += 4;
144 columnWidths = [abbr, title]; 144 columnWidths = [abbr, title];
145 } 145 }
146 146
147 newline() { 147 void newline() {
148 newlinesNeeded++; 148 newlinesNeeded++;
149 currentColumn = 0; 149 currentColumn = 0;
150 numHelpLines = 0; 150 numHelpLines = 0;
151 } 151 }
152 152
153 write(int column, String text) { 153 void write(int column, String text) {
154 var lines = text.split('\n'); 154 var lines = text.split('\n');
155 155
156 // Strip leading and trailing empty lines. 156 // Strip leading and trailing empty lines.
157 while (lines.length > 0 && lines[0].trim() == '') { 157 while (lines.length > 0 && lines[0].trim() == '') {
158 lines.removeRange(0, 1); 158 lines.removeRange(0, 1);
159 } 159 }
160 160
161 while (lines.length > 0 && lines[lines.length - 1].trim() == '') { 161 while (lines.length > 0 && lines[lines.length - 1].trim() == '') {
162 lines.removeLast(); 162 lines.removeLast();
163 } 163 }
164 164
165 for (var line in lines) { 165 for (var line in lines) {
166 writeLine(column, line); 166 writeLine(column, line);
167 } 167 }
168 } 168 }
169 169
170 writeLine(int column, String text) { 170 void writeLine(int column, String text) {
171 // Write any pending newlines. 171 // Write any pending newlines.
172 while (newlinesNeeded > 0) { 172 while (newlinesNeeded > 0) {
173 buffer.writeln(''); 173 buffer.writeln('');
174 newlinesNeeded--; 174 newlinesNeeded--;
175 } 175 }
176 176
177 // Advance until we are at the right column (which may mean wrapping around 177 // Advance until we are at the right column (which may mean wrapping around
178 // to the next line. 178 // to the next line.
179 while (currentColumn != column) { 179 while (currentColumn != column) {
180 if (currentColumn < NUM_COLUMNS - 1) { 180 if (currentColumn < NUM_COLUMNS - 1) {
(...skipping 20 matching lines...) Expand all
201 201
202 // Keep track of how many consecutive lines we've written in the last 202 // Keep track of how many consecutive lines we've written in the last
203 // column. 203 // column.
204 if (column == NUM_COLUMNS - 1) { 204 if (column == NUM_COLUMNS - 1) {
205 numHelpLines++; 205 numHelpLines++;
206 } else { 206 } else {
207 numHelpLines = 0; 207 numHelpLines = 0;
208 } 208 }
209 } 209 }
210 210
211 buildAllowedList(Option option) { 211 String buildAllowedList(Option option) {
212 var allowedBuffer = new StringBuffer(); 212 var allowedBuffer = new StringBuffer();
213 allowedBuffer.write('['); 213 allowedBuffer.write('[');
214 bool first = true; 214 bool first = true;
215 for (var allowed in option.allowed) { 215 for (var allowed in option.allowed) {
216 if (!first) allowedBuffer.write(', '); 216 if (!first) allowedBuffer.write(', ');
217 allowedBuffer.write(allowed); 217 allowedBuffer.write(allowed);
218 if (allowed == option.defaultValue) { 218 if (allowed == option.defaultValue) {
219 allowedBuffer.write(' (default)'); 219 allowedBuffer.write(' (default)');
220 } 220 }
221 first = false; 221 first = false;
222 } 222 }
223 allowedBuffer.write(']'); 223 allowedBuffer.write(']');
224 return allowedBuffer.toString(); 224 return allowedBuffer.toString();
225 } 225 }
226 } 226 }
227 227
228 /** Pads [source] to [length] by adding spaces at the end. */ 228 /** Pads [source] to [length] by adding spaces at the end. */
229 String padRight(String source, int length) { 229 String padRight(String source, int length) {
230 final result = new StringBuffer(); 230 final result = new StringBuffer();
231 result.write(source); 231 result.write(source);
232 232
233 while (result.length < length) { 233 while (result.length < length) {
234 result.write(' '); 234 result.write(' ');
235 } 235 }
236 236
237 return result.toString(); 237 return result.toString();
238 } 238 }
OLDNEW
« no previous file with comments | « tools/testing/dart/vendored_pkg/args/src/parser.dart ('k') | tools/testing/dart/vm_test_config.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698