diff --git a/idea/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt b/idea/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt index 3d61b487ed7..223a709ede1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt +++ b/idea/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt @@ -139,6 +139,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder { betweenInside(FUN_KEYWORD, IDENTIFIER, FUN).spaces(1) betweenInside(FUN_KEYWORD, TYPE_REFERENCE, FUN).spaces(1) + betweenInside(FUN_KEYWORD, VALUE_PARAMETER_LIST, FUN).spacing(0, 0, 0, false, 0) betweenInside(TYPE_REFERENCE, DOT, FUN).spacing(0, 0, 0, false, 0) betweenInside(DOT, IDENTIFIER, FUN).spacing(0, 0, 0, false, 0) afterInside(IDENTIFIER, FUN).spacing(0, 0, 0, false, 0) diff --git a/idea/testData/formatter/FunctionExpression.after.kt b/idea/testData/formatter/FunctionExpression.after.kt index 731b16e5c52..ff172fefb15 100644 --- a/idea/testData/formatter/FunctionExpression.after.kt +++ b/idea/testData/formatter/FunctionExpression.after.kt @@ -1,4 +1,4 @@ -val a = fun () { +val a = fun() { } val b = fun test() { } @@ -17,6 +17,8 @@ val c = fun() = 4 fun test() = fun test() = 4 fun test() { + test(fun() { + }) test(fun test() { }) test(fun test() = 5) diff --git a/idea/testData/formatter/FunctionExpression.kt b/idea/testData/formatter/FunctionExpression.kt index df1ca355711..fd52b7f2230 100644 --- a/idea/testData/formatter/FunctionExpression.kt +++ b/idea/testData/formatter/FunctionExpression.kt @@ -1,18 +1,21 @@ val a = fun () {} val b = fun test() {} -val c=fun(){} -val c=fun()=4 +val c=fun (){} +val c=fun ()=4 -val c=fun()= +val c=fun ()= 4 val c = fun() {} -val c = fun() = 4 +val c = fun () = 4 fun test() = fun test() = 4 fun test() { + test(fun + () { + }) test(fun test() {}) test(fun test() = 5) diff --git a/idea/testData/quickfix/migration/lambdaSyntax/lambdaInsideLambda.kt.after b/idea/testData/quickfix/migration/lambdaSyntax/lambdaInsideLambda.kt.after index 0d29ab9717a..202ba59ebe8 100644 --- a/idea/testData/quickfix/migration/lambdaSyntax/lambdaInsideLambda.kt.after +++ b/idea/testData/quickfix/migration/lambdaSyntax/lambdaInsideLambda.kt.after @@ -6,5 +6,5 @@ fun foo(a: Any) {} val a = foo a@ { - val a = fun (): Int = 1 + val a = fun(): Int = 1 } \ No newline at end of file diff --git a/idea/testData/quickfix/migration/lambdaSyntax/lambdaSyntaxMultiple.after.data.Sample.kt b/idea/testData/quickfix/migration/lambdaSyntax/lambdaSyntaxMultiple.after.data.Sample.kt index 80dd49d21bd..a2af686e6d2 100644 --- a/idea/testData/quickfix/migration/lambdaSyntax/lambdaSyntaxMultiple.after.data.Sample.kt +++ b/idea/testData/quickfix/migration/lambdaSyntax/lambdaSyntaxMultiple.after.data.Sample.kt @@ -3,4 +3,4 @@ val h = { -> } val l = bar@ fun Int.bar() { } -val s = (fun (): Int = 5)() \ No newline at end of file +val s = (fun(): Int = 5)() \ No newline at end of file diff --git a/idea/testData/quickfix/migration/lambdaSyntax/lambdaSyntaxMultiple.after.kt b/idea/testData/quickfix/migration/lambdaSyntax/lambdaSyntaxMultiple.after.kt index 111760b5324..f058cdb2185 100644 --- a/idea/testData/quickfix/migration/lambdaSyntax/lambdaSyntaxMultiple.after.kt +++ b/idea/testData/quickfix/migration/lambdaSyntax/lambdaSyntaxMultiple.after.kt @@ -1,8 +1,8 @@ // "Migrate lambda syntax in whole project" "true" -val a = fun (): Int { +val a = fun(): Int { - val b = fun (): Int = 5 + val b = fun(): Int = 5 return b() } \ No newline at end of file diff --git a/idea/testData/quickfix/migration/lambdaSyntax/lastStatementIsComment.kt.after b/idea/testData/quickfix/migration/lambdaSyntax/lastStatementIsComment.kt.after index 6c2cd489f94..524ae270efd 100644 --- a/idea/testData/quickfix/migration/lambdaSyntax/lastStatementIsComment.kt.after +++ b/idea/testData/quickfix/migration/lambdaSyntax/lastStatementIsComment.kt.after @@ -1,7 +1,7 @@ // "Migrate lambda syntax" "true" -val a = fun (p: Int): String { +val a = fun(p: Int): String { val v = p + 1 return v.toString() // returns v.toString() diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/smartEnter/SmartEnterTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/smartEnter/SmartEnterTest.kt index 48c1fa87f23..ec0f2f0bfea 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/smartEnter/SmartEnterTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/smartEnter/SmartEnterTest.kt @@ -871,7 +871,7 @@ class SmartEnterTest : JetLightCodeInsightFixtureTestCase() { """ , """ - fun (p: Int, s: String) { + fun(p: Int, s: String) { } """ @@ -886,7 +886,7 @@ class SmartEnterTest : JetLightCodeInsightFixtureTestCase() { , """ trait Some { - fun (p: Int) + fun(p: Int) } """ @@ -901,7 +901,7 @@ class SmartEnterTest : JetLightCodeInsightFixtureTestCase() { , """ class Some { - abstract fun (p: Int) + abstract fun(p: Int) } """