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

Unified Diff: pkg/analyzer/bin/formatter.dart

Issue 138143009: dartfmt patch file side-stepping. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/bin/formatter.dart
===================================================================
--- pkg/analyzer/bin/formatter.dart (revision 31842)
+++ pkg/analyzer/bin/formatter.dart (working copy)
@@ -24,9 +24,11 @@
bool machineFormat;
bool overwriteFileContents;
Selection selection;
-const followLinks = false;
+final List<String> paths = [];
+const FOLLOW_LINKS = false;
+
main(args) {
var options = argParser.parse(args);
if (options['help']) {
@@ -39,7 +41,8 @@
if (options.rest.isEmpty) {
_formatStdin(kind);
} else {
- _formatPaths(options.rest);
+ paths.addAll(options.rest);
+ _formatPaths(paths);
}
}
@@ -96,11 +99,15 @@
}
}
-_formatDirectory(dir) => dir.listSync(followLinks: followLinks)
+_formatDirectory(dir) => dir.listSync(followLinks: FOLLOW_LINKS)
.forEach((resource) => _formatResource(resource));
_formatFile(file) {
if (_isDartFile(file)) {
+ if (_isPatchFile(file) && !paths.contains(file.path)) {
+ _log('Skipping patch file "${file.path}"');
+ return;
+ }
try {
var buffer = new StringBuffer();
var rawSource = file.readAsStringSync();
@@ -116,6 +123,8 @@
}
}
+_isPatchFile(file) => file.path.endsWith('_patch.dart');
+
_isDartFile(file) => dartFileRegExp.hasMatch(path.basename(file.path));
_formatStdin(kind) {
« 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