Fixed formatter for function expression
This commit is contained in:
@@ -98,7 +98,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder {
|
|||||||
// ENUM_ENTRY - ENUM_ENTRY is exception
|
// ENUM_ENTRY - ENUM_ENTRY is exception
|
||||||
between(ENUM_ENTRY, DECLARATIONS).blankLines(1)
|
between(ENUM_ENTRY, DECLARATIONS).blankLines(1)
|
||||||
|
|
||||||
before(FUN).lineBreakInCode()
|
beforeInside(FUN, TokenSet.create(BODY, CLASS_BODY)).lineBreakInCode()
|
||||||
before(PROPERTY).lineBreakInCode()
|
before(PROPERTY).lineBreakInCode()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
val a = fun () {
|
||||||
|
}
|
||||||
|
val b = fun test() {
|
||||||
|
}
|
||||||
|
|
||||||
|
val c = fun() {
|
||||||
|
}
|
||||||
|
val c = fun() = 4
|
||||||
|
|
||||||
|
val c = fun() =
|
||||||
|
4
|
||||||
|
|
||||||
|
val c = fun() {
|
||||||
|
}
|
||||||
|
val c = fun() = 4
|
||||||
|
|
||||||
|
fun test() = fun test() = 4
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
test(fun test() {
|
||||||
|
})
|
||||||
|
test(fun test() = 5)
|
||||||
|
|
||||||
|
test(fun test() = fun test(a: Int) = 2)
|
||||||
|
|
||||||
|
2.(fun test() {
|
||||||
|
})()
|
||||||
|
|
||||||
|
(fun() = 4)
|
||||||
|
(fun() {
|
||||||
|
})
|
||||||
|
|
||||||
|
test(fun test() = 4)
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
val a = fun () {}
|
||||||
|
val b = fun test() {}
|
||||||
|
|
||||||
|
val c=fun(){}
|
||||||
|
val c=fun()=4
|
||||||
|
|
||||||
|
val c=fun()=
|
||||||
|
4
|
||||||
|
|
||||||
|
val c = fun() {}
|
||||||
|
val c = fun() = 4
|
||||||
|
|
||||||
|
fun test() = fun test() = 4
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
test(fun test() {})
|
||||||
|
test(fun test() = 5)
|
||||||
|
|
||||||
|
test(fun test() = fun test(a: Int) = 2)
|
||||||
|
|
||||||
|
2.(fun test() {})()
|
||||||
|
|
||||||
|
(fun()=4)
|
||||||
|
(fun(){})
|
||||||
|
|
||||||
|
test( fun test ( ) = 4 )
|
||||||
|
}
|
||||||
@@ -6,6 +6,5 @@ fun foo(a: Any) {}
|
|||||||
|
|
||||||
val a = foo @a {
|
val a = foo @a {
|
||||||
|
|
||||||
val a =
|
val a = fun (): Int = 1
|
||||||
fun (): Int = 1
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
// "Migrate lambda syntax" "true"
|
||||||
|
|
||||||
|
|
||||||
val a =
|
val a = fun Int.(a: Int): String = ""
|
||||||
fun Int.(a: Int): String = ""
|
|
||||||
+3
-5
@@ -1,8 +1,6 @@
|
|||||||
val h = { -> }
|
val h = { -> }
|
||||||
|
|
||||||
val l = @bar (
|
val l = @bar (fun Int.bar() {
|
||||||
fun Int.bar() {
|
})
|
||||||
})
|
|
||||||
|
|
||||||
val s = (
|
val s = (fun (): Int = 5)()
|
||||||
fun (): Int = 5)()
|
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
// "Migrate lambda syntax in whole project" "true"
|
// "Migrate lambda syntax in whole project" "true"
|
||||||
|
|
||||||
val a =
|
val a = fun (): Int {
|
||||||
fun (): Int {
|
val b = fun (): Int = 5
|
||||||
val b =
|
|
||||||
fun (): Int = 5
|
|
||||||
|
|
||||||
return b()
|
return b()
|
||||||
}
|
}
|
||||||
@@ -256,6 +256,12 @@ public class JetFormatterTestGenerated extends AbstractJetFormatterTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("FunctionExpression.after.kt")
|
||||||
|
public void testFunctionExpression() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/FunctionExpression.after.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("FunctionLineBreak.after.kt")
|
@TestMetadata("FunctionLineBreak.after.kt")
|
||||||
public void testFunctionLineBreak() throws Exception {
|
public void testFunctionLineBreak() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/FunctionLineBreak.after.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/FunctionLineBreak.after.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user