| OLD | NEW |
| 1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
| 2 | 2 |
| 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 4 // for details. All rights reserved. Use of this source code is governed by a | 4 // for details. All rights reserved. Use of this source code is governed by a |
| 5 // BSD-style license that can be found in the LICENSE file. | 5 // BSD-style license that can be found in the LICENSE file. |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:args/args.dart'; | 10 import 'package:args/args.dart'; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 length = -1; | 83 length = -1; |
| 84 } else { | 84 } else { |
| 85 throw new FormatterException('Line length is specified as an Integer or ' | 85 throw new FormatterException('Line length is specified as an Integer or ' |
| 86 'the value "Inf".'); | 86 'the value "Inf".'); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 return length; | 89 return length; |
| 90 } | 90 } |
| 91 | 91 |
| 92 | 92 |
| 93 Selection _parseSelection(selectionOption) { | 93 Selection _parseSelection(String selectionOption) { |
| 94 if (selectionOption != null) { | 94 if(selectionOption == null) return null; |
| 95 var units = selectionOption.split(','); | 95 |
| 96 if (units.length == 2) { | 96 var units = selectionOption.split(','); |
| 97 var offset = _toInt(units[0]); | 97 if (units.length == 2) { |
| 98 var length = _toInt(units[1]); | 98 var offset = _toInt(units[0]); |
| 99 if (offset != null && length != null) { | 99 var length = _toInt(units[1]); |
| 100 return new Selection(offset, length); | 100 if (offset != null && length != null) { |
| 101 } | 101 return new Selection(offset, length); |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 throw new FormatterException('Selections are specified as integer pairs ' | 104 throw new FormatterException('Selections are specified as integer pairs ' |
| 105 '(e.g., "(offset, length)".'); | 105 '(e.g., "(offset, length)".'); |
| 106 } | 106 } |
| 107 | 107 |
| 108 int _toInt(str) => int.parse(str, onError: (_) => null); | 108 int _toInt(str) => int.parse(str, onError: (_) => null); |
| 109 | 109 |
| 110 _formatPaths(paths) { | 110 _formatPaths(paths) { |
| 111 paths.forEach((path) { | 111 paths.forEach((path) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 'offset': formatResult.selection.offset, | 228 'offset': formatResult.selection.offset, |
| 229 'length': formatResult.selection.length | 229 'length': formatResult.selection.length |
| 230 } | 230 } |
| 231 }); | 231 }); |
| 232 | 232 |
| 233 /// Log the given [msg]. | 233 /// Log the given [msg]. |
| 234 _log(String msg) { | 234 _log(String msg) { |
| 235 //TODO(pquitslund): add proper log support | 235 //TODO(pquitslund): add proper log support |
| 236 print(msg); | 236 print(msg); |
| 237 } | 237 } |
| OLD | NEW |