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

Unified Diff: packages/dart_style/lib/src/io.dart

Issue 1521693002: Roll Observatory deps (charted -> ^0.3.0) (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years 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
Index: packages/dart_style/lib/src/io.dart
diff --git a/packages/dart_style/lib/src/io.dart b/packages/dart_style/lib/src/io.dart
index 765ac3e2f3b09575e293c6ef7736fd831cfb17dc..51f380585dc8486f17ff2474e3723d905dd12937 100644
--- a/packages/dart_style/lib/src/io.dart
+++ b/packages/dart_style/lib/src/io.dart
@@ -22,6 +22,8 @@ bool processDirectory(FormatterOptions options, Directory directory) {
options.reporter.showDirectory(directory.path);
var success = true;
+ var shownHiddenPaths = new Set<String>();
+
for (var entry in directory.listSync(
recursive: true, followLinks: options.followLinks)) {
var relative = p.relative(entry.path, from: directory.path);
@@ -34,8 +36,22 @@ bool processDirectory(FormatterOptions options, Directory directory) {
if (entry is! File || !entry.path.endsWith(".dart")) continue;
// If the path is in a subdirectory starting with ".", ignore it.
- if (p.split(relative).any((part) => part.startsWith("."))) {
- options.reporter.showHiddenFile(relative);
+ var parts = p.split(relative);
+ var hiddenIndex;
+ for (var i = 0; i < parts.length; i++) {
+ if (parts[i].startsWith(".")) {
+ hiddenIndex = i;
+ break;
+ }
+ }
+
+ if (hiddenIndex != null) {
+ // Since we'll hide everything inside the directory starting with ".",
+ // show the directory name once instead of once for each file.
+ var hiddenPath = p.joinAll(parts.take(hiddenIndex + 1));
+ if (shownHiddenPaths.add(hiddenPath)) {
+ options.reporter.showHiddenPath(hiddenPath);
+ }
continue;
}
@@ -51,12 +67,14 @@ bool processDirectory(FormatterOptions options, Directory directory) {
bool processFile(FormatterOptions options, File file, {String label}) {
if (label == null) label = file.path;
- var formatter = new DartFormatter(pageWidth: options.pageWidth);
+ var formatter =
+ new DartFormatter(indent: options.indent, pageWidth: options.pageWidth);
try {
var source = new SourceCode(file.readAsStringSync(), uri: file.path);
+ options.reporter.beforeFile(file, label);
var output = formatter.formatSource(source);
options.reporter
- .showFile(file, label, output, changed: source.text != output.text);
+ .afterFile(file, label, output, changed: source.text != output.text);
return true;
} on FormatterException catch (err) {
var color = Platform.operatingSystem != "windows" &&
« no previous file with comments | « packages/dart_style/lib/src/formatter_options.dart ('k') | packages/dart_style/lib/src/line_splitting/line_splitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698