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

Unified Diff: lib/src/source_visitor.dart

Issue 1498283002: Allow splitting in redirecting constructors. (Closed) Base URL: https://github.com/dart-lang/dart_style.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
« no previous file with comments | « CHANGELOG.md ('k') | test/regression/0400/0475.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 1cdd0bea0adb767b73716102ef3ccb831223d778..0da60dd4d76871d886ca8442a3e065bef28728b5 100644
--- a/lib/src/source_visitor.dart
+++ b/lib/src/source_visitor.dart
@@ -538,10 +538,15 @@ class SourceVisitor implements AstVisitor {
// ":" if the parameters and initialization list don't all fit on one line.
builder.startRule();
+ // If the redirecting constructor happens to wrap, we want to make sure
+ // the parameter list gets more deeply indented.
+ if (node.redirectedConstructor != null) builder.nestExpression();
+
_visitBody(node.parameters, node.body, () {
// Check for redirects or initializer lists.
if (node.redirectedConstructor != null) {
_visitConstructorRedirects(node);
+ builder.unnest();
} else if (node.initializers.isNotEmpty) {
_visitConstructorInitializers(node);
}
@@ -549,7 +554,8 @@ class SourceVisitor implements AstVisitor {
}
void _visitConstructorRedirects(ConstructorDeclaration node) {
- token(node.separator /* = */, before: space, after: space);
+ token(node.separator /* = */, before: space);
+ soloSplit();
visitCommaSeparatedNodes(node.initializers);
visit(node.redirectedConstructor);
}
« no previous file with comments | « CHANGELOG.md ('k') | test/regression/0400/0475.unit » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698