| 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 import 'dart:utf'; | 9 import 'dart:utf'; |
| 10 | 10 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 CodeKind.COMPILATION_UNIT, src, selection: selection); | 152 CodeKind.COMPILATION_UNIT, src, selection: selection); |
| 153 if (machineFormat) { | 153 if (machineFormat) { |
| 154 return _toJson(formatResult); | 154 return _toJson(formatResult); |
| 155 } | 155 } |
| 156 return formatResult.source; | 156 return formatResult.source; |
| 157 } | 157 } |
| 158 | 158 |
| 159 _toJson(formatResult) => | 159 _toJson(formatResult) => |
| 160 // Actual JSON format TBD | 160 // Actual JSON format TBD |
| 161 JSON.encode({'source': formatResult.source, | 161 JSON.encode({'source': formatResult.source, |
| 162 'selection': formatResult.selection.toString()}); | 162 'selection': { |
| 163 'offset': formatResult.selection.offset, |
| 164 'length': formatResult.selection.length |
| 165 } |
| 166 }); |
| 163 | 167 |
| 164 /// Log the given [msg]. | 168 /// Log the given [msg]. |
| 165 _log(String msg) { | 169 _log(String msg) { |
| 166 //TODO(pquitslund): add proper log support | 170 //TODO(pquitslund): add proper log support |
| 167 print(msg); | 171 print(msg); |
| 168 } | 172 } |
| OLD | NEW |