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

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

Issue 170403004: Fix to ensure decls with initializers get their own lines (dartbug.com/16849). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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/test/services/data/stmt_tests.data » ('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
===================================================================
--- pkg/analyzer/lib/src/services/formatter_impl.dart (revision 32869)
+++ pkg/analyzer/lib/src/services/formatter_impl.dart (working copy)
@@ -1318,7 +1318,32 @@
visitNodes(node.metadata, followedBy: newlines);
modifier(node.keyword);
visitNode(node.type, followedBy: space);
- visitCommaSeparatedNodes(node.variables);
+
+ var variables = node.variables;
+ // Decls with initializers get their own lines (dartbug.com/16849)
+ if (variables.any((v) => (v.initializer != null))) {
+ var size = variables.length;
+ if (size > 0) {
+ var variable;
+ for (var i = 0; i < size; i++) {
+ variable = variables[i];
+ if (i > 0) {
+ var comma = variable.beginToken.previous;
+ token(comma);
+ newlines();
+ }
+ if (i == 1) {
+ indent(2);
+ }
+ variable.accept(this);
+ }
+ if (size > 1) {
+ unindent(2);
+ }
+ }
+ } else {
+ visitCommaSeparatedNodes(node.variables);
+ }
}
visitVariableDeclarationStatement(VariableDeclarationStatement node) {
« no previous file with comments | « no previous file | pkg/analyzer/test/services/data/stmt_tests.data » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698