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

Unified Diff: lib/src/source_visitor.dart

Issue 824763004: Allow splitting in clauses in C-style for loop. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | test/regression/100.stmt » ('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 7739689a9811e67dcdf04383c147f44046874de9..f201da40e7efa8a3cdc9d1ca78781e7e34185fd9 100644
--- a/lib/src/source_visitor.dart
+++ b/lib/src/source_visitor.dart
@@ -487,6 +487,14 @@ class SourceVisitor implements AstVisitor {
token(node.semicolon);
}
+ visitEnumConstantDeclaration(EnumConstantDeclaration node) {
+ throw new UnimplementedError("Enum formatting is not implemented yet.");
+ }
+
+ visitEnumDeclaration(EnumDeclaration node) {
+ throw new UnimplementedError("Enum formatting is not implemented yet.");
+ }
+
visitExportDirective(ExportDirective node) {
visitDeclarationMetadata(node.metadata);
token(node.keyword);
@@ -561,14 +569,6 @@ class SourceVisitor implements AstVisitor {
visit(node.body);
}
- visitEnumConstantDeclaration(EnumConstantDeclaration node) {
- throw new UnimplementedError("Enum formatting is not implemented yet.");
- }
-
- visitEnumDeclaration(EnumDeclaration node) {
- throw new UnimplementedError("Enum formatting is not implemented yet.");
- }
-
visitFormalParameterList(FormalParameterList node) {
token(node.leftParenthesis);
@@ -610,27 +610,52 @@ class SourceVisitor implements AstVisitor {
token(node.forKeyword);
space();
token(node.leftParenthesis);
+
+ _writer.startMultisplit();
+
+ // The initialization clause.
if (node.initialization != null) {
visit(node.initialization);
} else {
if (node.variables == null) {
space();
} else {
- visit(node.variables);
+ // Indent split variables more so they aren't at the same level
+ // as the rest of the loop clauses.
+ _writer.indent(2);
+
+ var declaration = node.variables;
+ visitDeclarationMetadata(declaration.metadata);
+ modifier(declaration.keyword);
+ visitNode(declaration.type, after: space);
+
+ visitCommaSeparatedNodes(declaration.variables, between: () {
+ _writer.multisplit(space: true, nest: true);
+ });
+
+ _writer.unindent(2);
}
}
+
token(node.leftSeparator);
- space();
+ _writer.multisplit(nest: true, space: true);
+
+ // The condition clause.
visit(node.condition);
token(node.rightSeparator);
+
+ // The update clause.
if (node.updaters != null) {
- space();
- visitCommaSeparatedNodes(node.updaters);
+ _writer.multisplit(nest: true, space: true);
+ visitCommaSeparatedNodes(node.updaters,
+ between: () => _writer.multisplit(nest: true, space: true));
}
+
token(node.rightParenthesis);
- if (node.body is! EmptyStatement) {
- space();
- }
+ _writer.endMultisplit();
+
+ // The body.
+ if (node.body is! EmptyStatement) space();
visit(node.body);
}
« no previous file with comments | « no previous file | test/regression/100.stmt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698