Move statement: move into lambda correctly
#KT-17887 Fixed
This commit is contained in:
committed by
Vladimir Dolzhenko
parent
19824201e2
commit
3c1b41c020
@@ -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
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// MOVE: down
|
||||
fun test() {
|
||||
<caret>val foo = foo()
|
||||
Bar().also {
|
||||
if (foo != null) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun foo(): String? = null
|
||||
|
||||
class Bar
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// MOVE: down
|
||||
fun test() {
|
||||
Bar().also {
|
||||
<caret>val foo = foo()
|
||||
if (foo != null) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun foo(): String? = null
|
||||
|
||||
class Bar
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user