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

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

Issue 22872012: Remove Encoding-enum from dart:io and add interface in dart:convert. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typo. Created 7 years, 3 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 | « pkg/analyzer_experimental/bin/analyzer.dart ('k') | pkg/barback/lib/src/asset.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 #!/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:io'; 7 import 'dart:io';
8 8
9 import 'package:args/args.dart'; 9 import 'package:args/args.dart';
10 10
(...skipping 19 matching lines...) Expand all
30 _formatFiles(files) { 30 _formatFiles(files) {
31 for (var file in files) { 31 for (var file in files) {
32 _formatFile(file); 32 _formatFile(file);
33 } 33 }
34 } 34 }
35 35
36 _formatFile(path) { 36 _formatFile(path) {
37 var buffer = new StringBuffer(); 37 var buffer = new StringBuffer();
38 var file = new File(path); 38 var file = new File(path);
39 file.openRead() 39 file.openRead()
40 .transform(new StringDecoder()) 40 .transform(UTF8.decoder)
41 .listen((data) => buffer.write(data), 41 .listen((data) => buffer.write(data),
42 onError: (error) => print('Error, could not open "$path"'), 42 onError: (error) => print('Error, could not open "$path"'),
43 onDone: () => print(_formatCU(buffer.toString()))); 43 onDone: () => print(_formatCU(buffer.toString())));
44 } 44 }
45 45
46 _formatStdin(options) { 46 _formatStdin(options) {
47 _log('not supported yet!'); 47 _log('not supported yet!');
48 // stdin.transform(new StringDecoder()) 48 // stdin.transform(new StringDecoder())
49 // .listen((String data) => print(data), 49 // .listen((String data) => print(data),
50 // onError: (error) => print('Error reading from stdin'), 50 // onError: (error) => print('Error reading from stdin'),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 /// Format the given [src] as a compilation unit. 85 /// Format the given [src] as a compilation unit.
86 String _formatCU(src, {options: const FormatterOptions()}) => 86 String _formatCU(src, {options: const FormatterOptions()}) =>
87 new CodeFormatter(options).format(CodeKind.COMPILATION_UNIT, src); 87 new CodeFormatter(options).format(CodeKind.COMPILATION_UNIT, src);
88 88
89 /// Log the given [msg]. 89 /// Log the given [msg].
90 _log(String msg) { 90 _log(String msg) {
91 //TODO(pquitslund): add proper log support 91 //TODO(pquitslund): add proper log support
92 print(msg); 92 print(msg);
93 } 93 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/bin/analyzer.dart ('k') | pkg/barback/lib/src/asset.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698