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

Unified Diff: lib/src/io.dart

Issue 968053004: Allow command-line API to pass in selection to preserve. Fix #194. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Update version Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/formatter_options.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/io.dart
diff --git a/lib/src/io.dart b/lib/src/io.dart
index a1f536176094ecf6bfea8a604fda74b274b09bf9..e7c855554b15934bbdc75f8b3d4c94f84ed3a285 100644
--- a/lib/src/io.dart
+++ b/lib/src/io.dart
@@ -11,6 +11,7 @@ import 'package:path/path.dart' as p;
import 'dart_formatter.dart';
import 'formatter_options.dart';
import 'formatter_exception.dart';
+import 'source_code.dart';
/// Runs the formatter on every .dart file in [path] (and its subdirectories),
/// and replaces them with their formatted output.
@@ -47,15 +48,15 @@ bool processDirectory(FormatterOptions options, Directory directory) {
/// Runs the formatter on [file].
///
/// Returns `true` if successful or `false` if an error occurred.
-bool processFile(FormatterOptions options, File file,
- {String label}) {
+bool processFile(FormatterOptions options, File file, {String label}) {
if (label == null) label = file.path;
var formatter = new DartFormatter(pageWidth: options.pageWidth);
try {
- var source = file.readAsStringSync();
- var output = formatter.format(source, uri: file.path);
- options.reporter.showFile(file, label, output, changed: source != output);
+ var source = new SourceCode(file.readAsStringSync(), uri: file.path);
+ var output = formatter.formatSource(source);
+ options.reporter.showFile(file, label, output,
+ changed: source.text != output.text);
return true;
} on FormatterException catch (err) {
stderr.writeln(err.message());
« no previous file with comments | « lib/src/formatter_options.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698