OLD | NEW |
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 var formatter = new DartFormatter(pageWidth: options.pageWidth); | 54 var formatter = new DartFormatter(pageWidth: options.pageWidth); |
55 try { | 55 try { |
56 var source = file.readAsStringSync(); | 56 var source = file.readAsStringSync(); |
57 var output = formatter.format(source, uri: file.path); | 57 var output = formatter.format(source, uri: file.path); |
58 options.reporter.showFile(file, label, output, changed: source != output); | 58 options.reporter.showFile(file, label, output, changed: source != output); |
59 return true; | 59 return true; |
60 } on FormatterException catch (err) { | 60 } on FormatterException catch (err) { |
61 stderr.writeln(err.message()); | 61 stderr.writeln(err.message()); |
62 } catch (err, stack) { | 62 } catch (err, stack) { |
63 stderr.writeln('''Hit a bug in the formatter when formatting $label | 63 stderr.writeln('''Hit a bug in the formatter when formatting $label. |
64 Please report at: github.com/dart-lang/dart_style/issues | 64 Please report at: github.com/dart-lang/dart_style/issues |
65 $err | 65 $err |
66 $stack'''); | 66 $stack'''); |
67 } | 67 } |
68 | 68 |
69 return false; | 69 return false; |
70 } | 70 } |
OLD | NEW |