| 40 columns | |
| ### Tests "block-like" formatting of method chains where we don't split at |
| ### "." while still allowing newlines in some argument lists. |
| >>> Block format single call with split regular arguments. |
| target.method(argument1, argument2, argument3); |
| <<< |
| target.method( |
| argument1, |
| argument2, |
| argument3, |
| ); |
| >>> Block format single call with collection argument. |
| target.method([element1, element2, element3]); |
| <<< |
| target.method([ |
| element1, |
| element2, |
| element3, |
| ]); |
| >>> Block format single call with function argument. |
| target.method(() { body; }); |
| <<< |
| target.method(() { |
| body; |
| }); |
| >>> Block format single call with line comment in argument list. |
| target.method(// comment |
| ); |
| <<< |
| target.method( |
| // comment |
| ); |
| >>> Block format single call with block comment in argument list. |
| target.method(/* a very long comment */); |
| <<< |
| target.method( |
| /* a very long comment */ |
| ); |
| >>> Allow block format chain with leading properties. |
| target.property1.property2.method(argument1, argument2); |
| <<< |
| target.property1.property2.method( |
| argument1, |
| argument2, |
| ); |
| >>> If leading properties split, then don't block format chain. |
| target.property1.property2.property3.method(argument1, argument2, argument3); |
| <<< |
| target.property1.property2.property3 |
| .method( |
| argument1, |
| argument2, |
| argument3, |
| ); |
| >>> Block format chain on trailing split argument list with leading unsplittable calls. |
| target.zero().one().two().method(argument); |
| <<< |
| target.zero().one().two().method( |
| argument, |
| ); |
| >>> No block format chain on split argument list with leading splittable calls. |
| target.zero().one(1).two(1, 2).method(argument1, argument2, argument3); |
| <<< |
| target |
| .zero() |
| .one(1) |
| .two(1, 2) |
| .method( |
| argument1, |
| argument2, |
| argument3, |
| ); |
| >>> Block format chain with splittable calls and function at end. |
| compiler |
| .run(script) |
| .then((_) { |
| body; |
| }); |
| <<< |
| compiler.run(script).then((_) { |
| body; |
| }); |
| >>> Block format chain with splittable calls and collection at end. |
| compiler |
| .run(script) |
| .then([ |
| element1, |
| element2, |
| element3, |
| ]); |
| <<< |
| compiler.run(script).then([ |
| element1, |
| element2, |
| element3, |
| ]); |
| >>> No block format chain if the preceding calls don't fit on one line. |
| compiler |
| .run(longerScriptArgumentHere) |
| .then((_) { |
| body; |
| }); |
| <<< |
| compiler |
| .run(longerScriptArgumentHere) |
| .then((_) { |
| body; |
| }); |
| >>> Split after properties. |
| target.property1.property2.property3.method(argument); |
| <<< |
| target.property1.property2.property3 |
| .method(argument); |
| >>> Allow a trailing property after a block-formatted call. |
| target.method([element1, element2]).property; |
| <<< |
| target.method([ |
| element1, |
| element2, |
| ]).property; |
| >>> Allow a trailing empty call after a block-formatted call. |
| target.method([element1, element2]).another(); |
| <<< |
| target.method([ |
| element1, |
| element2, |
| ]).another(); |
| >>> Don't allow a trailing property after a regular splittable call. |
| target.method(argument1, argument2).property; |
| <<< |
| target |
| .method(argument1, argument2) |
| .property; |
| >>> Don't allow a trailing empty call after a regular splittable call. |
| target.method(argument1, argument2).another(); |
| <<< |
| target |
| .method(argument1, argument2) |
| .another(); |
| >>> Don't allow a trailing non-empty call after a block-formatted call. |
| target.method([element1, element2]).another(1); |
| <<< |
| target |
| .method([element1, element2]) |
| .another(1); |
| >>> Don't allow a trailing non-empty call after a block-formatted call. |
| target.method([element1, element2]).another(/* c */); |
| <<< |
| target |
| .method([element1, element2]) |
| .another(/* c */); |
| >>> Allow postfix before block-formatted call. |
| target.prop!.other[1]().method(argument1, argument2); |
| <<< |
| target.prop!.other[1]().method( |
| argument1, |
| argument2, |
| ); |
| >>> Allow postfix `!` on block call. |
| target.method(argument1, argument2, argument3)!; |
| <<< |
| target.method( |
| argument1, |
| argument2, |
| argument3, |
| )!; |
| >>> Postfix index on block call. |
| target.method(argument1, argument2, argument3)[index]; |
| <<< |
| target.method( |
| argument1, |
| argument2, |
| argument3, |
| )[index]; |
| >>> Postfix call on block call. |
| target.method(argument1, argument2, argument3)(argument4); |
| <<< |
| target.method( |
| argument1, |
| argument2, |
| argument3, |
| )(argument4); |
| >>> Postfix call on block call. |
| target.method(argument1, argument2, argument3) |
| (argument4, argument5, argument6, argument7); |
| <<< |
| target.method( |
| argument1, |
| argument2, |
| argument3, |
| )( |
| argument4, |
| argument5, |
| argument6, |
| argument7, |
| ); |