Split property declaration: don't add parentheses for anonymous function

#KT-7593 Fixed
This commit is contained in:
Toshiaki Kameyama
2018-12-18 13:43:23 +09:00
committed by Mikhail Glukhikh
parent c1f75d2324
commit ea0f9d124d
4 changed files with 22 additions and 0 deletions
@@ -495,6 +495,14 @@ public class KtPsiUtil {
return false;
}
// 'x = fun {}' case
if (parentElement instanceof KtBinaryExpression &&
parentOperation == KtTokens.EQ &&
innerExpression instanceof KtNamedFunction &&
currentInner == ((KtBinaryExpression) parentElement).getRight()) {
return false;
}
if (innerExpression instanceof KtBinaryExpression) {
// '(x operator return [...]) operator ...' case
if (parentElement instanceof KtBinaryExpression) {
@@ -0,0 +1,4 @@
fun test() {
<caret>val f = fun () {
}
}
@@ -0,0 +1,5 @@
fun test() {
val f: () -> Unit
f = fun () {
}
}
@@ -8577,6 +8577,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/declarations/split"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
}
@TestMetadata("anonymousFunction.kt")
public void testAnonymousFunction() throws Exception {
runTest("idea/testData/intentions/declarations/split/anonymousFunction.kt");
}
@TestMetadata("longInit.kt")
public void testLongInit() throws Exception {
runTest("idea/testData/intentions/declarations/split/longInit.kt");