OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart_style.src.formatter_options; | 5 library dart_style.src.formatter_options; |
6 | 6 |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'source_code.dart'; | 10 import 'source_code.dart'; |
11 | 11 |
12 /// Global options that affect how the formatter produces and uses its outputs. | 12 /// Global options that affect how the formatter produces and uses its outputs. |
13 class FormatterOptions { | 13 class FormatterOptions { |
14 /// The [OutputReporter] used to show the formatting results. | 14 /// The [OutputReporter] used to show the formatting results. |
15 final OutputReporter reporter; | 15 final OutputReporter reporter; |
16 | 16 |
| 17 /// The number of spaces of indentation to prefix the output with. |
| 18 final int indent; |
| 19 |
17 /// The number of columns that formatted output should be constrained to fit | 20 /// The number of columns that formatted output should be constrained to fit |
18 /// within. | 21 /// within. |
19 final int pageWidth; | 22 final int pageWidth; |
20 | 23 |
21 /// Whether symlinks should be traversed when formatting a directory. | 24 /// Whether symlinks should be traversed when formatting a directory. |
22 final bool followLinks; | 25 final bool followLinks; |
23 | 26 |
24 FormatterOptions(this.reporter, | 27 FormatterOptions(this.reporter, |
25 {this.pageWidth: 80, this.followLinks: false}); | 28 {this.indent: 0, this.pageWidth: 80, this.followLinks: false}); |
26 } | 29 } |
27 | 30 |
28 /// How the formatter reports the results it produces. | 31 /// How the formatter reports the results it produces. |
29 abstract class OutputReporter { | 32 abstract class OutputReporter { |
30 /// Prints only the names of files whose contents are different from their | 33 /// Prints only the names of files whose contents are different from their |
31 /// formatted version. | 34 /// formatted version. |
32 static final dryRun = new _DryRunReporter(); | 35 static final dryRun = new _DryRunReporter(); |
33 | 36 |
34 /// Prints the formatted results of each file to stdout. | 37 /// Prints the formatted results of each file to stdout. |
35 static final print = new _PrintReporter(); | 38 static final print = new _PrintReporter(); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 var elapsed = new DateTime.now().difference(_ongoing.remove(label)); | 190 var elapsed = new DateTime.now().difference(_ongoing.remove(label)); |
188 if (elapsed.inMilliseconds >= 10) { | 191 if (elapsed.inMilliseconds >= 10) { |
189 _elapsed[label] = elapsed; | 192 _elapsed[label] = elapsed; |
190 } else { | 193 } else { |
191 _elided++; | 194 _elided++; |
192 } | 195 } |
193 | 196 |
194 _inner.afterFile(file, label, output, changed: changed); | 197 _inner.afterFile(file, label, output, changed: changed); |
195 } | 198 } |
196 } | 199 } |
OLD | NEW |