| Index: lib/src/source_visitor.dart
|
| diff --git a/lib/src/source_visitor.dart b/lib/src/source_visitor.dart
|
| index 1cdd0bea0adb767b73716102ef3ccb831223d778..38f148f7ff2ad2dcf6359c025ceea873746f78bc 100644
|
| --- a/lib/src/source_visitor.dart
|
| +++ b/lib/src/source_visitor.dart
|
| @@ -185,7 +185,17 @@ class SourceVisitor implements AstVisitor {
|
|
|
| visitBinaryExpression(BinaryExpression node) {
|
| builder.startSpan();
|
| - builder.nestExpression();
|
| +
|
| + // If a binary operator sequence appears immediately after a `=>`, don't
|
| + // add an extra level of nesting. Instead, let the subsequent operands line
|
| + // up with the first, as in:
|
| + //
|
| + // method() =>
|
| + // argument &&
|
| + // argument &&
|
| + // argument;
|
| + var isArrowBody = node.parent is ExpressionFunctionBody;
|
| + if (!isArrowBody) builder.nestExpression();
|
|
|
| // Start lazily so we don't force the operator to split if a line comment
|
| // appears before the first operand.
|
| @@ -217,7 +227,7 @@ class SourceVisitor implements AstVisitor {
|
|
|
| builder.endBlockArgumentNesting();
|
|
|
| - builder.unnest();
|
| + if (!isArrowBody) builder.unnest();
|
| builder.endSpan();
|
| builder.endRule();
|
| }
|
| @@ -709,7 +719,10 @@ class SourceVisitor implements AstVisitor {
|
| // Split after the "=>", using the rule created before the parameters
|
| // by _visitBody().
|
| split();
|
| - builder.endRule();
|
| +
|
| + // If the body is a binary operator expression, then we want to force the
|
| + // split at `=>` if the operators split. See visitBinaryExpression().
|
| + if (node.expression is! BinaryExpression) builder.endRule();
|
|
|
| if (_isInLambda(node)) builder.endSpan();
|
|
|
| @@ -719,6 +732,8 @@ class SourceVisitor implements AstVisitor {
|
| builder.endSpan();
|
| builder.endBlockArgumentNesting();
|
|
|
| + if (node.expression is BinaryExpression) builder.endRule();
|
| +
|
| token(node.semicolon);
|
| }
|
|
|
|
|