Move statement: move into lambda correctly

#KT-17887 Fixed
This commit is contained in:
Toshiaki Kameyama
2019-08-03 18:02:32 +02:00
committed by Vladimir Dolzhenko
parent 19824201e2
commit 3c1b41c020
4 changed files with 33 additions and 0 deletions
@@ -291,6 +291,10 @@ class KotlinExpressionMover : AbstractKotlinUpDownMover() {
element is KtLoopExpression
) return null
(element as? KtQualifiedExpression)?.selectorExpression?.let {
return getDSLLambdaBlock(editor, it, down)
}
val callExpression =
KtPsiUtil.getOutermostDescendantElement(element, down, IS_CALL_EXPRESSION) as KtCallExpression? ?: return null
val functionLiterals = callExpression.lambdaArguments
@@ -0,0 +1,12 @@
// MOVE: down
fun test() {
<caret>val foo = foo()
Bar().also {
if (foo != null) {
}
}
}
fun foo(): String? = null
class Bar
@@ -0,0 +1,12 @@
// MOVE: down
fun test() {
Bar().also {
<caret>val foo = foo()
if (foo != null) {
}
}
}
fun foo(): String? = null
class Bar
@@ -1093,6 +1093,11 @@ public class MoveStatementTestGenerated extends AbstractMoveStatementTest {
runTest("idea/testData/codeInsight/moveUpDown/expressions/lambdaInIf2.kt");
}
@TestMetadata("lambdaInQualifiedExpression.kt")
public void testLambdaInQualifiedExpression() throws Exception {
runTest("idea/testData/codeInsight/moveUpDown/expressions/lambdaInQualifiedExpression.kt");
}
@TestMetadata("lambdaInTry.kt")
public void testLambdaInTry() throws Exception {
runTest("idea/testData/codeInsight/moveUpDown/expressions/lambdaInTry.kt");