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

Unified Diff: pkg/analyzer/lib/src/services/formatter_impl.dart

Issue 319063004: Formatter: don't indent EOL comment at the beginning of a line. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 | pkg/analyzer/lib/src/services/writer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/services/formatter_impl.dart
diff --git a/pkg/analyzer/lib/src/services/formatter_impl.dart b/pkg/analyzer/lib/src/services/formatter_impl.dart
index cfa81c9548c6d7ba4e0686d374724bceb2afb805..6998a192f97815273123532db5445b7875f47143 100644
--- a/pkg/analyzer/lib/src/services/formatter_impl.dart
+++ b/pkg/analyzer/lib/src/services/formatter_impl.dart
@@ -1686,6 +1686,10 @@ class SourceVisitor implements AstVisitor {
}
+ /// Test if this EOL [comment] is at the beginning of a line.
+ bool isAtBOL(Token comment) =>
+ lineInfo.getLocation(comment.offset).columnNumber == 1;
+
/// Test if this [comment] is at the end of a line.
bool isAtEOL(Token comment) =>
comment != null && comment.toString().trim().startsWith(twoSlashes) &&
@@ -1701,6 +1705,11 @@ class SourceVisitor implements AstVisitor {
}
}
+ // Don't indent commented-out lines
+ if (isAtBOL(comment)) {
+ writer.currentLine.clear();
+ }
+
append(comment.toString().trim());
}
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/services/writer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698