mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Remove receiver when unwrapping trailing lambda KTIJ-21562
IntelliJ now transforms
kotlin.run {
println("abc")
}
into
println("abc")
when unwrapping.
closes https://github.com/JetBrains/intellij-community/pull/1996
GitOrigin-RevId: 7f547279382544eabe9252ec210857f62ba07815
This commit is contained in:
committed by
intellij-monorepo-bot
parent
499529bd07
commit
f73da4c0ea
+9
-2
@@ -19,7 +19,14 @@ public class KotlinLambdaUnwrapper extends KotlinUnwrapRemoveBase {
|
||||
PsiElement parent = lambda.getParent();
|
||||
|
||||
if (parent instanceof KtValueArgument) {
|
||||
return PsiTreeUtil.getParentOfType(parent, KtCallExpression.class, true);
|
||||
KtCallExpression callExpression = PsiTreeUtil.getParentOfType(parent, KtCallExpression.class, true);
|
||||
if (callExpression != null) {
|
||||
PsiElement parentParent = callExpression.getParent();
|
||||
if (parentParent instanceof KtQualifiedExpression) {
|
||||
return (KtElement) parentParent;
|
||||
}
|
||||
}
|
||||
return callExpression;
|
||||
}
|
||||
|
||||
if (parent instanceof KtCallExpression) {
|
||||
@@ -39,7 +46,7 @@ public class KotlinLambdaUnwrapper extends KotlinUnwrapRemoveBase {
|
||||
|
||||
KtLambdaExpression lambda = (KtLambdaExpression) e;
|
||||
KtBlockExpression body = lambda.getBodyExpression();
|
||||
KtElement enclosingElement = getLambdaEnclosingElement((KtLambdaExpression) e);
|
||||
KtElement enclosingElement = getLambdaEnclosingElement(lambda);
|
||||
|
||||
if (body == null || enclosingElement == null) return false;
|
||||
|
||||
|
||||
+5
@@ -289,6 +289,11 @@ public abstract class UnwrapRemoveTestGenerated extends AbstractUnwrapRemoveTest
|
||||
public void testLambdaPropertyInBlock() throws Exception {
|
||||
runTest("testData/codeInsight/unwrapAndRemove/unwrapLambda/lambdaPropertyInBlock.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaWithQualifiedReceiver.kt")
|
||||
public void testLambdaWithQualifiedReceiver() throws Exception {
|
||||
runTest("testData/codeInsight/unwrapAndRemove/unwrapLambda/lambdaWithQualifiedReceiver.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// OPTION: 0
|
||||
fun test() {
|
||||
kotlin.run <caret>{
|
||||
println(123)
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// OPTION: 0
|
||||
fun test() {
|
||||
println(123)<caret>
|
||||
}
|
||||
Reference in New Issue
Block a user