Formatter: support Chop down if long for Chained method calls
#KT-23929 Fixed #KT-33553 Fixed
This commit is contained in:
@@ -4,7 +4,9 @@ interface Test {
|
||||
|
||||
fun test(t: Test) {
|
||||
t.foo()
|
||||
|
||||
t().foo()
|
||||
t()!!.foo().foo()
|
||||
((t()!!).foo().foo().foo()).foo()
|
||||
t.foo()
|
||||
|
||||
t.foo()
|
||||
|
||||
+3
-1
@@ -4,7 +4,9 @@ interface Test {
|
||||
|
||||
fun test(t: Test) {
|
||||
t . foo()
|
||||
|
||||
t() . foo()
|
||||
t() !! . foo() .foo()
|
||||
( ( t() !!) . foo() .foo() .foo()) .foo()
|
||||
t.
|
||||
foo()
|
||||
|
||||
|
||||
@@ -3,7 +3,10 @@ val x = foo
|
||||
.baz()
|
||||
.quux()
|
||||
|
||||
val y = xyzzy(foo.bar().baz().quux())
|
||||
val y = xyzzy(foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux())
|
||||
|
||||
fun foo() {
|
||||
foo
|
||||
@@ -27,5 +30,25 @@ fun foo() {
|
||||
.quux()
|
||||
}
|
||||
|
||||
fun top() = ""
|
||||
.plus("")
|
||||
.plus("")
|
||||
|
||||
class C {
|
||||
fun member() = ""
|
||||
.plus("")
|
||||
.plus("")
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
fun local() = ""
|
||||
.plus("")
|
||||
.plus("")
|
||||
|
||||
val anonymous = fun() = ""
|
||||
.plus("")
|
||||
.plus("")
|
||||
}
|
||||
|
||||
// SET_INT: METHOD_CALL_CHAIN_WRAP = 2
|
||||
// SET_FALSE: WRAP_FIRST_METHOD_IN_CALL_CHAIN
|
||||
@@ -2,7 +2,9 @@ val x = foo.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
|
||||
val y = xyzzy(foo.bar().baz().quux())
|
||||
val y = xyzzy(foo.bar()
|
||||
.baz()
|
||||
.quux())
|
||||
|
||||
fun foo() {
|
||||
foo.bar()
|
||||
@@ -22,5 +24,21 @@ fun foo() {
|
||||
.quux()
|
||||
}
|
||||
|
||||
fun top() = "".plus("")
|
||||
.plus("")
|
||||
|
||||
class C {
|
||||
fun member() = "".plus("")
|
||||
.plus("")
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
fun local() = "".plus("")
|
||||
.plus("")
|
||||
|
||||
val anonymous = fun() = "".plus("")
|
||||
.plus("")
|
||||
}
|
||||
|
||||
// SET_INT: METHOD_CALL_CHAIN_WRAP = 2
|
||||
// SET_FALSE: WRAP_FIRST_METHOD_IN_CALL_CHAIN
|
||||
@@ -12,5 +12,14 @@ fun foo() {
|
||||
return foo.bar().baz().quux()
|
||||
}
|
||||
|
||||
fun top() = "".plus("").plus("")
|
||||
class C {
|
||||
fun member() = "".plus("").plus("")
|
||||
}
|
||||
fun foo() {
|
||||
fun local() = "".plus("").plus("")
|
||||
val anonymous = fun() = "".plus("").plus("")
|
||||
}
|
||||
|
||||
// SET_INT: METHOD_CALL_CHAIN_WRAP = 2
|
||||
// SET_FALSE: WRAP_FIRST_METHOD_IN_CALL_CHAIN
|
||||
@@ -0,0 +1,244 @@
|
||||
val x = foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
|
||||
val y = xyzzy(foo.bar().baz().quux())
|
||||
|
||||
fun foo() {
|
||||
foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
|
||||
z = (((foo()))!!).bar()
|
||||
|
||||
z += (foo.bar().baz().quux().foo.bar().baz().quux().foo.bar()!!)
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
|
||||
return ((foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux())
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar())
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
}
|
||||
|
||||
// SET_INT: METHOD_CALL_CHAIN_WRAP = 5
|
||||
// SET_FALSE: WRAP_FIRST_METHOD_IN_CALL_CHAIN
|
||||
// SET_FALSE: CONTINUATION_INDENT_FOR_CHAINED_CALLS
|
||||
@@ -0,0 +1,239 @@
|
||||
val x = foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
|
||||
val y = xyzzy(foo.bar().baz().quux())
|
||||
|
||||
fun foo() {
|
||||
foo.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
|
||||
z = (((foo()))!!).bar()
|
||||
|
||||
z += (foo.bar().baz().quux().foo.bar().baz().quux().foo.bar()!!).baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
|
||||
return ((foo.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()).foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()).baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
.foo
|
||||
.bar()
|
||||
.baz()
|
||||
.quux()
|
||||
}
|
||||
|
||||
// SET_INT: METHOD_CALL_CHAIN_WRAP = 5
|
||||
// SET_FALSE: WRAP_FIRST_METHOD_IN_CALL_CHAIN
|
||||
// SET_FALSE: CONTINUATION_INDENT_FOR_CHAINED_CALLS
|
||||
@@ -0,0 +1,19 @@
|
||||
val x = foo
|
||||
.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux()
|
||||
|
||||
val y = xyzzy(foo.bar().baz().quux())
|
||||
|
||||
fun foo() {
|
||||
foo.bar().baz().quux()
|
||||
.foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux()
|
||||
|
||||
z = (( ( foo()) )!! ).bar()
|
||||
|
||||
z += (foo.bar().baz().quux().foo.bar().baz().quux().foo.bar() !!) .baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux()
|
||||
|
||||
return ((foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux()).foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar()).baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux().foo.bar().baz().quux()
|
||||
}
|
||||
|
||||
// SET_INT: METHOD_CALL_CHAIN_WRAP = 5
|
||||
// SET_FALSE: WRAP_FIRST_METHOD_IN_CALL_CHAIN
|
||||
// SET_FALSE: CONTINUATION_INDENT_FOR_CHAINED_CALLS
|
||||
@@ -0,0 +1,12 @@
|
||||
fun f(list: List<Int>) {
|
||||
val result = list
|
||||
.filter { it % 2 == 0 }
|
||||
.max() ?: -1
|
||||
list
|
||||
.filter { it % 2 == 0 }
|
||||
.max()
|
||||
?: -1
|
||||
}
|
||||
|
||||
// SET_INT: METHOD_CALL_CHAIN_WRAP = 2
|
||||
// SET_FALSE: WRAP_FIRST_METHOD_IN_CALL_CHAIN
|
||||
@@ -0,0 +1,10 @@
|
||||
fun f(list: List<Int>) {
|
||||
val result = list.filter { it % 2 == 0 }
|
||||
.max() ?: -1
|
||||
list.filter { it % 2 == 0 }
|
||||
.max()
|
||||
?: -1
|
||||
}
|
||||
|
||||
// SET_INT: METHOD_CALL_CHAIN_WRAP = 2
|
||||
// SET_FALSE: WRAP_FIRST_METHOD_IN_CALL_CHAIN
|
||||
@@ -0,0 +1,8 @@
|
||||
fun f(list: List<Int>) {
|
||||
val result = list.filter { it % 2 == 0 }.max() ?: -1
|
||||
list.filter { it % 2 == 0 }.max()
|
||||
?: -1
|
||||
}
|
||||
|
||||
// SET_INT: METHOD_CALL_CHAIN_WRAP = 2
|
||||
// SET_FALSE: WRAP_FIRST_METHOD_IN_CALL_CHAIN
|
||||
Reference in New Issue
Block a user