Chromium Code Reviews| Index: pkg/analyzer/bin/formatter.dart |
| diff --git a/pkg/analyzer/bin/formatter.dart b/pkg/analyzer/bin/formatter.dart |
| index 0466f40df5042446743cfcedab6981d78ed04335..01eb5306a2ed26b2938325e441a1ec879a34b50b 100755 |
| --- a/pkg/analyzer/bin/formatter.dart |
| +++ b/pkg/analyzer/bin/formatter.dart |
| @@ -18,7 +18,7 @@ final dartFileRegExp = new RegExp(r'^[^.].*\.dart$', caseSensitive: false); |
| final argParser = _initArgParser(); |
| final defaultSelection = new Selection(-1, -1); |
| -var formatterSettings; |
| +FormatterOptions formatterSettings; |
| CodeKind kind; |
| bool machineFormat; |
| @@ -39,7 +39,7 @@ const MAX_LINE_FLAG = 'max_line_length'; |
| const FOLLOW_LINKS = false; |
| -main(args) { |
| +main(List<String> args) { |
|
pquitslund
2014/02/10 04:01:50
Is this ever NOT a List of Strings? What's the be
|
| var options = argParser.parse(args); |
| if (options['help']) { |
| _printUsage(); |
| @@ -56,7 +56,7 @@ main(args) { |
| } |
| } |
| -_readOptions(options) { |
| +_readOptions(ArgResults options) { |
|
pquitslund
2014/02/10 04:01:50
Really? It's like you're provoking me... ;) Sure
|
| kind = _parseKind(options[KIND_FLAG]); |
| machineFormat = options[MACHINE_FLAG]; |
| overwriteFileContents = options[WRITE_FLAG]; |
| @@ -66,7 +66,7 @@ _readOptions(options) { |
| pageWidth: _parseLineLength(options[MAX_LINE_FLAG])); |
| } |
| -CodeKind _parseKind(kindOption) { |
| +CodeKind _parseKind(String kindOption) { |
|
pquitslund
2014/02/10 04:01:50
OK, and especially here. Isn't it obvious from th
|
| switch(kindOption) { |
| case 'stmt' : |
| return CodeKind.STATEMENT; |
| @@ -90,15 +90,15 @@ int _parseLineLength(String lengthOption) { |
| } |
| -Selection _parseSelection(selectionOption) { |
| - if (selectionOption != null) { |
| - var units = selectionOption.split(','); |
| - if (units.length == 2) { |
| - var offset = _toInt(units[0]); |
| - var length = _toInt(units[1]); |
| - if (offset != null && length != null) { |
| - return new Selection(offset, length); |
| - } |
| +Selection _parseSelection(String selectionOption) { |
| + if(selectionOption == null) return null; |
| + |
| + var units = selectionOption.split(','); |
| + if (units.length == 2) { |
| + var offset = _toInt(units[0]); |
| + var length = _toInt(units[1]); |
| + if (offset != null && length != null) { |
| + return new Selection(offset, length); |
| } |
| } |
| throw new FormatterException('Selections are specified as integer pairs ' |
| @@ -152,9 +152,9 @@ _formatFile(file) { |
| } |
| } |
| -_isPatchFile(file) => file.path.endsWith('_patch.dart'); |
| +bool _isPatchFile(file) => file.path.endsWith('_patch.dart'); |
| -_isDartFile(file) => dartFileRegExp.hasMatch(path.basename(file.path)); |
| +bool _isDartFile(file) => dartFileRegExp.hasMatch(path.basename(file.path)); |
| _formatStdin(kind) { |
| var input = new StringBuffer(); |
| @@ -221,7 +221,7 @@ String _format(src, kind) { |
| return formatResult.source; |
| } |
| -_toJson(formatResult) => |
| +String _toJson(formatResult) => |
| // Actual JSON format TBD |
| JSON.encode({'source': formatResult.source, |
| 'selection': { |