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

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

Issue 26502003: Update formatter main to use preferred Utf8Decoder. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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:convert'; 7 import 'dart:convert';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:utf';
10 9
11 import 'package:args/args.dart'; 10 import 'package:args/args.dart';
12 import 'package:path/path.dart' as path; 11 import 'package:path/path.dart' as path;
13 12
14 import 'package:analyzer_experimental/src/services/formatter_impl.dart'; 13 import 'package:analyzer_experimental/src/services/formatter_impl.dart';
15 14
16 15
17 const BINARY_NAME = 'dartfmt'; 16 const BINARY_NAME = 'dartfmt';
18 final dartFileRegExp = new RegExp(r'^[^.].*\.dart$', caseSensitive: false); 17 final dartFileRegExp = new RegExp(r'^[^.].*\.dart$', caseSensitive: false);
19 final argParser = _initArgParser(); 18 final argParser = _initArgParser();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } catch (e) { 102 } catch (e) {
104 _log('Unable to format "${file.path}": $e'); 103 _log('Unable to format "${file.path}": $e');
105 } 104 }
106 } 105 }
107 } 106 }
108 107
109 _isDartFile(file) => dartFileRegExp.hasMatch(path.basename(file.path)); 108 _isDartFile(file) => dartFileRegExp.hasMatch(path.basename(file.path));
110 109
111 _formatStdin(options) { 110 _formatStdin(options) {
112 var input = new StringBuffer(); 111 var input = new StringBuffer();
113 stdin.transform(new Utf8DecoderTransformer()) 112 stdin.transform(new Utf8Decoder())
114 .listen((data) => input.write(data), 113 .listen((data) => input.write(data),
115 onError: (error) => _log('Error reading from stdin'), 114 onError: (error) => _log('Error reading from stdin'),
116 onDone: () => print(_formatCU(input.toString()))); 115 onDone: () => print(_formatCU(input.toString())));
117 } 116 }
118 117
119 /// Initialize the arg parser instance. 118 /// Initialize the arg parser instance.
120 ArgParser _initArgParser() { 119 ArgParser _initArgParser() {
121 // NOTE: these flags are placeholders only! 120 // NOTE: these flags are placeholders only!
122 var parser = new ArgParser(); 121 var parser = new ArgParser();
123 parser.addFlag('write', abbr: 'w', negatable: false, 122 parser.addFlag('write', abbr: 'w', negatable: false,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 'offset': formatResult.selection.offset, 173 'offset': formatResult.selection.offset,
175 'length': formatResult.selection.length 174 'length': formatResult.selection.length
176 } 175 }
177 }); 176 });
178 177
179 /// Log the given [msg]. 178 /// Log the given [msg].
180 _log(String msg) { 179 _log(String msg) {
181 //TODO(pquitslund): add proper log support 180 //TODO(pquitslund): add proper log support
182 print(msg); 181 print(msg);
183 } 182 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698