| Index: pkg/analyzer_experimental/bin/formatter.dart
|
| ===================================================================
|
| --- pkg/analyzer_experimental/bin/formatter.dart (revision 28325)
|
| +++ pkg/analyzer_experimental/bin/formatter.dart (working copy)
|
| @@ -17,6 +17,7 @@
|
| const BINARY_NAME = 'dartfmt';
|
| final dartFileRegExp = new RegExp(r'^[^.].*\.dart$', caseSensitive: false);
|
| final argParser = _initArgParser();
|
| +final defaultSelection = new Selection(-1, -1);
|
|
|
| bool machineFormat;
|
| bool overwriteFileContents;
|
| @@ -31,7 +32,7 @@
|
| }
|
|
|
| _readOptions(options);
|
| -
|
| +
|
| if (options.rest.isEmpty) {
|
| _formatStdin(options);
|
| } else {
|
| @@ -122,6 +123,8 @@
|
| parser.addOption('selection', abbr: 's',
|
| help: 'Specify selection information as an offset,length pair '
|
| '(e.g., -s "0,4").');
|
| + parser.addFlag('transform', abbr: 't', negatable: true,
|
| + help: 'Perform code transformations.');
|
| parser.addFlag('help', abbr: 'h', negatable: false,
|
| help: 'Print this usage information.');
|
| return parser;
|
| @@ -151,12 +154,15 @@
|
| var formatResult = new CodeFormatter(options).format(
|
| CodeKind.COMPILATION_UNIT, src, selection: selection);
|
| if (machineFormat) {
|
| + if (formatResult.selection == null) {
|
| + formatResult.selection = defaultSelection;
|
| + }
|
| return _toJson(formatResult);
|
| }
|
| return formatResult.source;
|
| }
|
|
|
| -_toJson(formatResult) =>
|
| +_toJson(formatResult) =>
|
| // Actual JSON format TBD
|
| JSON.encode({'source': formatResult.source,
|
| 'selection': {
|
|
|