Try to keep constructor calls together. Fix #119.
BUG=https://github.com/dart-lang/dart_style/issues/119
R=kevmoo@google.com
Review URL: https://chromiumcodereview.appspot.com//826393005
diff --git a/lib/src/source_visitor.dart b/lib/src/source_visitor.dart
index 88719b0..e0780ff 100644
--- a/lib/src/source_visitor.dart
+++ b/lib/src/source_visitor.dart
@@ -819,10 +819,12 @@
}
visitInstanceCreationExpression(InstanceCreationExpression node) {
+ _writer.startSpan();
token(node.keyword);
space();
visit(node.constructorName);
visit(node.argumentList);
+ _writer.endSpan();
}
visitIntegerLiteral(IntegerLiteral node) {
diff --git a/test/regression/119.stmt b/test/regression/119.stmt
new file mode 100644
index 0000000..a055f29
--- /dev/null
+++ b/test/regression/119.stmt
@@ -0,0 +1,14 @@
+>>> (indent 4)
+ boardData
+ ..drawPixels(op.getBitmapData('game_board_side_top'), tbr, new Point(
+ 112 + i * 80, 0));
+<<<
+ boardData
+ ..drawPixels(op.getBitmapData('game_board_side_top'), tbr,
+ new Point(112 + i * 80, 0));
+>>> (indent 6)
+ var initialOffset = new Vector(
+ SquareElement.SIZE * c.x, SquareElement.SIZE * c.y);
+<<<
+ var initialOffset =
+ new Vector(SquareElement.SIZE * c.x, SquareElement.SIZE * c.y);
\ No newline at end of file
diff --git a/test/splitting/constructors.unit b/test/splitting/constructors.unit
index 8687d3c..02862c4 100644
--- a/test/splitting/constructors.unit
+++ b/test/splitting/constructors.unit
@@ -31,4 +31,10 @@
Foo(int a, int b)
: super(a),
this.b = b == null ? 0 : b;
-}
\ No newline at end of file
+}
+>>> try to keep constructor call together
+var longIdentifier = new Thing(
+ argument, argument);
+<<<
+var longIdentifier =
+ new Thing(argument, argument);
\ No newline at end of file