blob: 952efe91d731ed438a4e87e4c6ba4cd3c095008a [file] [log] [blame]
40 columns |
>>> split all chained calls if they don't fit on one line
compiler.something().something().something();
<<<
compiler
.something()
.something()
.something();
>>> do not split chained calls if not needed
compiler.something().something().some();
<<<
compiler.something().something().some();
>>> don't split before implicit receiver
return
call({'type': type, 'id': id})
.then(deserializeAsset);
<<<
return call({'type': type, 'id': id})
.then(deserializeAsset);
>>> trailing functions in a chain do not force it to split
compiler
.run(script)
.then((_) {
body;
});
<<<
compiler.run(script).then((_) {
body;
});
>>> a function in the middle of a chain is indented
compiler.a().b((_) {body;}).c().d();
<<<
compiler
.a()
.b((_) {
body;
})
.c()
.d();
>>> a function in the middle of a chain is indented
compiler.a().b((_) {body;}).somethingLong().somethingLong().somethingLong();
<<<
compiler
.a()
.b((_) {
body;
})
.somethingLong()
.somethingLong()
.somethingLong();
>>> a function in the middle of a chain is indented
compiler.somethingLong().somethingLong().somethingLong((_) {
body;
}).a().b();
<<<
compiler
.somethingLong()
.somethingLong()
.somethingLong((_) {
body;
})
.a()
.b();
>>> one trailing call does not force function to indent
compiler.somethingLong().somethingLong().somethingLong((_) {
body;
}).a();
<<<
compiler
.somethingLong()
.somethingLong()
.somethingLong((_) {
body;
}).a();
>>> nest calls one more than target
someVeryLongExpression = someVeryLongExpression.someLongMethod();
<<<
someVeryLongExpression =
someVeryLongExpression
.someLongMethod();
>>> split properties after a method chain
compiler.method().method().method().property.property;
<<<
compiler
.method()
.method()
.method()
.property
.property;
>>> split properties in a method chain
compiler.method().property.method().property.method();
<<<
compiler
.method()
.property
.method()
.property
.method();
>>> do not split leading properties in a chain
compiler.property.property.method().method().method();
<<<
compiler.property.property
.method()
.method()
.method();
>>> do not split leading properties even if others splits
compiler.property.method().property.method();
<<<
compiler.property
.method()
.property
.method();
>>> split between a pair of properties
avian.bovine.canine.equine.feline.piscine.orycteropodian.camelid;
<<<
avian.bovine.canine.equine.feline
.piscine.orycteropodian.camelid;
>>> split before all properties if they don't fit on two lines
avian.bovine.canine.equine.feline.piscine.orycteropodian.camelid
.rangiferine;
<<<
avian
.bovine
.canine
.equine
.feline
.piscine
.orycteropodian
.camelid
.rangiferine;
>>> unsplit cascade unsplit method
object.method().method()..c()..c();
<<<
object.method().method()..c()..c();
>>> split cascade unsplit method
object.method().method()..cascade()..cascade();
<<<
object.method().method()
..cascade()
..cascade();
>>> unsplit cascade split method
object.method().method().method().method()..cascade()..cascade();
<<<
object
.method()
.method()
.method()
.method()..cascade()..cascade();
>>> split cascade split method
object.method().method().method().method()..cascade()..cascade()..cascade();
<<<
object
.method()
.method()
.method()
.method()
..cascade()
..cascade()
..cascade();
>>> cascade setters on method chain
object.method().method().method().method()..x=1..y=2;
<<<
object
.method()
.method()
.method()
.method()
..x = 1
..y = 2;
>>> conditional invocation
object?.method().method()?.method().method();
<<<
object
?.method()
.method()
?.method()
.method();
>>> index in property chain
someReceiverObject.property1.property2
.property3[0]
.property4
.property5
.property6;
<<<
someReceiverObject
.property1
.property2
.property3[0]
.property4
.property5
.property6;
>>> chained indexes
someReceiverObject.property1.property2
.property3[argument]
[argument][argument]
.property4
.property5
.property6;
<<<
someReceiverObject
.property1
.property2
.property3[argument][argument]
[argument]
.property4
.property5
.property6;
>>> index on method call
someReceiverObject.property1.property2
.method3()[0]
.property4
.property5
.property6;
<<<
someReceiverObject.property1.property2
.method3()[0]
.property4
.property5
.property6;
>>> target splits more deeply than method chain
someTargetFunction(argument, argument, argument).method().method();
<<<
someTargetFunction(
argument, argument, argument)
.method()
.method();
>>> splitting the target forces methods to split
someVeryLongTargetFunction(argument, argument).one().two();
<<<
someVeryLongTargetFunction(
argument, argument)
.one()
.two();
>>> target splits more deeply than property chain
someTargetFunction(argument, argument, argument).property.property;
<<<
someTargetFunction(
argument, argument, argument)
.property
.property;
>>> splitting the target forces methods to split
someVeryLongTargetFunction(argument, argument).one.two;
<<<
someVeryLongTargetFunction(
argument, argument)
.one
.two;
>>> do not split on "." when target is list
[element, element, element, element, element].someLongMethod();
<<<
[
element,
element,
element,
element,
element
].someLongMethod();
>>> do not split on "." when target is map
{"key": "value", "another": "another value"}.someLongMethod();
<<<
{
"key": "value",
"another": "another value"
}.someLongMethod();
>>> do not split on "." when target is function literal passed to method
method(() {;}).someLongMethod();
<<<
method(() {
;
}).someLongMethod();
>>> do not split on "." when target is function literal passed to constructor
new Foo(() {;}).someLongMethod();
<<<
new Foo(() {
;
}).someLongMethod();
>>> do not split on "." when target is function literal passed to function
(function)(() {;}).someLongMethod();
<<<
(function)(() {
;
}).someLongMethod();