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

Side by Side Diff: lib/src/io.dart

Issue 1470263004: Add "-i" to command line to specify leading indent. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « lib/src/formatter_options.dart ('k') | test/command_line_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart_style.src.io; 5 library dart_style.src.io;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:path/path.dart' as p; 9 import 'package:path/path.dart' as p;
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 return success; 61 return success;
62 } 62 }
63 63
64 /// Runs the formatter on [file]. 64 /// Runs the formatter on [file].
65 /// 65 ///
66 /// Returns `true` if successful or `false` if an error occurred. 66 /// Returns `true` if successful or `false` if an error occurred.
67 bool processFile(FormatterOptions options, File file, {String label}) { 67 bool processFile(FormatterOptions options, File file, {String label}) {
68 if (label == null) label = file.path; 68 if (label == null) label = file.path;
69 69
70 var formatter = new DartFormatter(pageWidth: options.pageWidth); 70 var formatter =
71 new DartFormatter(indent: options.indent, pageWidth: options.pageWidth);
71 try { 72 try {
72 var source = new SourceCode(file.readAsStringSync(), uri: file.path); 73 var source = new SourceCode(file.readAsStringSync(), uri: file.path);
73 options.reporter.beforeFile(file, label); 74 options.reporter.beforeFile(file, label);
74 var output = formatter.formatSource(source); 75 var output = formatter.formatSource(source);
75 options.reporter 76 options.reporter
76 .afterFile(file, label, output, changed: source.text != output.text); 77 .afterFile(file, label, output, changed: source.text != output.text);
77 return true; 78 return true;
78 } on FormatterException catch (err) { 79 } on FormatterException catch (err) {
79 var color = Platform.operatingSystem != "windows" && 80 var color = Platform.operatingSystem != "windows" &&
80 stdioType(stderr) == StdioType.TERMINAL; 81 stdioType(stderr) == StdioType.TERMINAL;
81 82
82 stderr.writeln(err.message(color: color)); 83 stderr.writeln(err.message(color: color));
83 } catch (err, stack) { 84 } catch (err, stack) {
84 stderr.writeln('''Hit a bug in the formatter when formatting $label. 85 stderr.writeln('''Hit a bug in the formatter when formatting $label.
85 Please report at: github.com/dart-lang/dart_style/issues 86 Please report at: github.com/dart-lang/dart_style/issues
86 $err 87 $err
87 $stack'''); 88 $stack''');
88 } 89 }
89 90
90 return false; 91 return false;
91 } 92 }
OLDNEW
« no previous file with comments | « lib/src/formatter_options.dart ('k') | test/command_line_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698