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

Unified Diff: pkg/analyzer_experimental/bin/formatter.dart

Issue 26280005: Formatter code transform bit-flip support. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
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': {

Powered by Google App Engine
This is Rietveld 408576698