Correctly indent the RHS of 'is' and 'as' expressions.
I'm surprised this has been wrong for so long.
R=kevmoo@google.com
Review URL: https://codereview.chromium.org//2521383002 .
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 08fda23..113306b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
# 0.2.12-dev
* Add support for assert() in constructor initializers.
+* Correctly indent the right-hand side of `is` and `as` expressions.
# 0.2.11+1
diff --git a/lib/src/source_visitor.dart b/lib/src/source_visitor.dart
index 9c4cd2c..f10cdd0 100644
--- a/lib/src/source_visitor.dart
+++ b/lib/src/source_visitor.dart
@@ -159,11 +159,13 @@
visitAsExpression(AsExpression node) {
builder.startSpan();
+ builder.nestExpression();
visit(node.expression);
soloSplit();
token(node.asOperator);
space();
visit(node.type);
+ builder.unnest();
builder.endSpan();
}
@@ -1240,12 +1242,14 @@
visitIsExpression(IsExpression node) {
builder.startSpan();
+ builder.nestExpression();
visit(node.expression);
soloSplit();
token(node.isOperator);
token(node.notOperator);
space();
visit(node.type);
+ builder.unnest();
builder.endSpan();
}
diff --git a/test/splitting/mixed.stmt b/test/splitting/mixed.stmt
index 33cdba4..97ba507 100644
--- a/test/splitting/mixed.stmt
+++ b/test/splitting/mixed.stmt
@@ -210,4 +210,16 @@
veryLongFunction() =>
longArgument +
longArgument +
- longArgument;
\ No newline at end of file
+ longArgument;
+>>> initialize with as expression
+var longVariableName = identifierSoLongItWraps as SomeClassName;
+<<<
+var longVariableName =
+ identifierSoLongItWraps
+ as SomeClassName;
+>>> initialize with is expression
+var longVariableName = identifierSoLongItWraps is SomeClassName;
+<<<
+var longVariableName =
+ identifierSoLongItWraps
+ is SomeClassName;
\ No newline at end of file