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

Unified Diff: lib/src/source_visitor.dart

Issue 1173663004: Insert a blank line before and after classes. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Created 5 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 | « CHANGELOG.md ('k') | test/regression/168.unit » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/source_visitor.dart
diff --git a/lib/src/source_visitor.dart b/lib/src/source_visitor.dart
index d40eee502b531fd087a5c49b59e036f75daa5a2f..339fae168c1103806719e14a9180086e4a0bb82c 100644
--- a/lib/src/source_visitor.dart
+++ b/lib/src/source_visitor.dart
@@ -435,8 +435,25 @@ class SourceVisitor implements AstVisitor {
}
visitNodes(directives, between: oneOrTwoNewlines);
- visitNodes(node.declarations,
- before: twoNewlines, between: oneOrTwoNewlines);
+
+ if (node.declarations.isNotEmpty) {
+ twoNewlines();
+
+ for (var i = 0; i < node.declarations.length; i++) {
+ visit(node.declarations[i]);
+
+ if (i < node.declarations.length - 1) {
+ // Require blank lines around classes.
+ if (node.declarations[i] is ClassDeclaration ||
+ node.declarations[i + 1] is ClassDeclaration) {
+ twoNewlines();
+ } else {
+ // Functions and variables can be more tightly packed.
+ oneOrTwoNewlines();
+ }
+ }
+ }
+ }
}
visitConditionalExpression(ConditionalExpression node) {
« no previous file with comments | « CHANGELOG.md ('k') | test/regression/168.unit » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698