Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: pkg/analyzer/bin/formatter.dart

Issue 149663005: Selection parsing fix. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 Selection _parseSelection(selectionOption) { 93 Selection _parseSelection(selectionOption) {
94 if (selectionOption != null) { 94 if (selectionOption != null) {
95 var units = selectionOption.split(','); 95 var units = selectionOption.split(',');
96 if (units.length == 2) { 96 if (units.length == 2) {
97 var offset = _toInt(units[0]); 97 var offset = _toInt(units[0]);
98 var length = _toInt(units[1]); 98 var length = _toInt(units[1]);
99 if (offset != null && length != null) { 99 if (offset != null && length != null) {
100 return new Selection(offset, length); 100 return new Selection(offset, length);
101 } 101 }
102 } 102 }
103 throw new FormatterException('Selections are specified as integer pairs '
104 '(e.g., "(offset, length)".');
105 } 103 }
104 throw new FormatterException('Selections are specified as integer pairs '
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) {
112 if (FileSystemEntity.isDirectorySync(path)) { 112 if (FileSystemEntity.isDirectorySync(path)) {
113 _formatDirectory(new Directory(path)); 113 _formatDirectory(new Directory(path));
114 } else { 114 } else {
115 _formatFile(new File(path)); 115 _formatFile(new File(path));
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698