Split property declaration: don't add parentheses for anonymous function
#KT-7593 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
c1f75d2324
commit
ea0f9d124d
@@ -495,6 +495,14 @@ public class KtPsiUtil {
|
|||||||
return false;
|
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) {
|
if (innerExpression instanceof KtBinaryExpression) {
|
||||||
// '(x operator return [...]) operator ...' case
|
// '(x operator return [...]) operator ...' case
|
||||||
if (parentElement instanceof KtBinaryExpression) {
|
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);
|
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")
|
@TestMetadata("longInit.kt")
|
||||||
public void testLongInit() throws Exception {
|
public void testLongInit() throws Exception {
|
||||||
runTest("idea/testData/intentions/declarations/split/longInit.kt");
|
runTest("idea/testData/intentions/declarations/split/longInit.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user