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

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

Issue 709493002: Fix 'Unused local variable' hints in analyzer and analysis_server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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/bin/analyzer.dart ('k') | pkg/analyzer/lib/src/services/formatter_impl.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:convert'; 7 import 'dart:convert';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:args/args.dart'; 10 import 'package:args/args.dart';
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 _formatDirectory(dir) => dir.listSync(followLinks: FOLLOW_LINKS) 147 _formatDirectory(dir) => dir.listSync(followLinks: FOLLOW_LINKS)
148 .forEach((resource) => _formatResource(resource)); 148 .forEach((resource) => _formatResource(resource));
149 149
150 _formatFile(file) { 150 _formatFile(file) {
151 if (_isDartFile(file)) { 151 if (_isDartFile(file)) {
152 if (_isPatchFile(file) && !paths.contains(file.path)) { 152 if (_isPatchFile(file) && !paths.contains(file.path)) {
153 _log('Skipping patch file "${file.path}"'); 153 _log('Skipping patch file "${file.path}"');
154 return; 154 return;
155 } 155 }
156 try { 156 try {
157 var buffer = new StringBuffer();
158 var rawSource = file.readAsStringSync(); 157 var rawSource = file.readAsStringSync();
159 var formatted = _format(rawSource, CodeKind.COMPILATION_UNIT); 158 var formatted = _format(rawSource, CodeKind.COMPILATION_UNIT);
160 if (overwriteFileContents) { 159 if (overwriteFileContents) {
161 // Only touch files files whose contents will be changed 160 // Only touch files files whose contents will be changed
162 if (rawSource != formatted) { 161 if (rawSource != formatted) {
163 file.writeAsStringSync(formatted); 162 file.writeAsStringSync(formatted);
164 } 163 }
165 } else { 164 } else {
166 print(formatted); 165 print(formatted);
167 } 166 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 'offset': formatResult.selection.offset, 250 'offset': formatResult.selection.offset,
252 'length': formatResult.selection.length 251 'length': formatResult.selection.length
253 } 252 }
254 }); 253 });
255 254
256 /// Log the given [msg]. 255 /// Log the given [msg].
257 _log(String msg) { 256 _log(String msg) {
258 //TODO(pquitslund): add proper log support 257 //TODO(pquitslund): add proper log support
259 print(msg); 258 print(msg);
260 } 259 }
OLDNEW
« no previous file with comments | « pkg/analyzer/bin/analyzer.dart ('k') | pkg/analyzer/lib/src/services/formatter_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698