KT-3791 (Move statement moves lambda parameters out of lambda itself) Fixed
This commit is contained in:
@@ -2,6 +2,7 @@ package org.jetbrains.jet.plugin.codeInsight.upDownMover;
|
|||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.intellij.codeInsight.editorActions.moveUpDown.LineRange;
|
import com.intellij.codeInsight.editorActions.moveUpDown.LineRange;
|
||||||
|
import com.intellij.lang.ASTNode;
|
||||||
import com.intellij.openapi.editor.Document;
|
import com.intellij.openapi.editor.Document;
|
||||||
import com.intellij.openapi.editor.Editor;
|
import com.intellij.openapi.editor.Editor;
|
||||||
import com.intellij.openapi.util.Pair;
|
import com.intellij.openapi.util.Pair;
|
||||||
@@ -213,6 +214,13 @@ public class JetExpressionMover extends AbstractJetUpDownMover {
|
|||||||
if (parent instanceof JetFunctionLiteral) {
|
if (parent instanceof JetFunctionLiteral) {
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
newBlock = findClosestBlock(((JetFunctionLiteral) parent).getBodyExpression(), down, false);
|
newBlock = findClosestBlock(((JetFunctionLiteral) parent).getBodyExpression(), down, false);
|
||||||
|
|
||||||
|
if (!down) {
|
||||||
|
ASTNode arrow = ((JetFunctionLiteral) parent).getArrowNode();
|
||||||
|
if (arrow != null) {
|
||||||
|
end = arrow.getPsi();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
newBlock = findClosestBlock(sibling, down, true);
|
newBlock = findClosestBlock(sibling, down, true);
|
||||||
}
|
}
|
||||||
@@ -254,6 +262,12 @@ public class JetExpressionMover extends AbstractJetUpDownMover {
|
|||||||
if (blockLikeElement != null) {
|
if (blockLikeElement != null) {
|
||||||
if (down) {
|
if (down) {
|
||||||
end = JetPsiUtil.findChildByType(blockLikeElement, JetTokens.LBRACE);
|
end = JetPsiUtil.findChildByType(blockLikeElement, JetTokens.LBRACE);
|
||||||
|
if (blockLikeElement instanceof JetFunctionLiteral) {
|
||||||
|
ASTNode arrow = ((JetFunctionLiteral) blockLikeElement).getArrowNode();
|
||||||
|
if (arrow != null) {
|
||||||
|
end = arrow.getPsi();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
start = JetPsiUtil.findChildByType(blockLikeElement, JetTokens.RBRACE);
|
start = JetPsiUtil.findChildByType(blockLikeElement, JetTokens.RBRACE);
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// MOVE: down
|
||||||
|
fun foo() {
|
||||||
|
<caret>println("foo")
|
||||||
|
run(1, 2) {
|
||||||
|
x ->
|
||||||
|
println("bar")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// MOVE: down
|
||||||
|
fun foo() {
|
||||||
|
run(1, 2) {
|
||||||
|
x ->
|
||||||
|
<caret>println("foo")
|
||||||
|
println("bar")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// MOVE: down
|
||||||
|
fun foo() {
|
||||||
|
<caret>println("foo")
|
||||||
|
val x = run(1, 2) {
|
||||||
|
x ->
|
||||||
|
println("bar")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// MOVE: down
|
||||||
|
fun foo() {
|
||||||
|
val x = run(1, 2) {
|
||||||
|
x ->
|
||||||
|
<caret>println("foo")
|
||||||
|
println("bar")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// MOVE: up
|
||||||
|
fun foo() {
|
||||||
|
run(1, 2) {
|
||||||
|
x ->
|
||||||
|
<caret>println("foo")
|
||||||
|
println("bar")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// MOVE: up
|
||||||
|
fun foo() {
|
||||||
|
<caret>println("foo")
|
||||||
|
run(1, 2) {
|
||||||
|
x ->
|
||||||
|
println("bar")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// MOVE: up
|
||||||
|
fun foo() {
|
||||||
|
val x = run(1, 2) {
|
||||||
|
x ->
|
||||||
|
<caret>println("foo")
|
||||||
|
println("bar")
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
// MOVE: up
|
||||||
|
fun foo() {
|
||||||
|
<caret>println("foo")
|
||||||
|
val x = run(1, 2) {
|
||||||
|
x ->
|
||||||
|
println("bar")
|
||||||
|
}
|
||||||
|
}
|
||||||
+20
@@ -867,6 +867,11 @@ public class CodeMoverTestGenerated extends AbstractCodeMoverTest {
|
|||||||
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/intoClosure2.kt");
|
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/intoClosure2.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("intoClosureWithParams1.kt")
|
||||||
|
public void testIntoClosureWithParams1() throws Exception {
|
||||||
|
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/intoClosureWithParams1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("intoNestedClosure1.kt")
|
@TestMetadata("intoNestedClosure1.kt")
|
||||||
public void testIntoNestedClosure1() throws Exception {
|
public void testIntoNestedClosure1() throws Exception {
|
||||||
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/intoNestedClosure1.kt");
|
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/intoNestedClosure1.kt");
|
||||||
@@ -877,6 +882,11 @@ public class CodeMoverTestGenerated extends AbstractCodeMoverTest {
|
|||||||
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/intoNestedClosure2.kt");
|
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/intoNestedClosure2.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("intoNestedClosureWithParams1.kt")
|
||||||
|
public void testIntoNestedClosureWithParams1() throws Exception {
|
||||||
|
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/intoNestedClosureWithParams1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lambda1.kt")
|
@TestMetadata("lambda1.kt")
|
||||||
public void testLambda1() throws Exception {
|
public void testLambda1() throws Exception {
|
||||||
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/lambda1.kt");
|
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/lambda1.kt");
|
||||||
@@ -902,6 +912,11 @@ public class CodeMoverTestGenerated extends AbstractCodeMoverTest {
|
|||||||
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/outOfClosure2.kt");
|
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/outOfClosure2.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("outOfClosureWithParams1.kt")
|
||||||
|
public void testOutOfClosureWithParams1() throws Exception {
|
||||||
|
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/outOfClosureWithParams1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("outOfNestedClosure1.kt")
|
@TestMetadata("outOfNestedClosure1.kt")
|
||||||
public void testOutOfNestedClosure1() throws Exception {
|
public void testOutOfNestedClosure1() throws Exception {
|
||||||
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/outOfNestedClosure1.kt");
|
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/outOfNestedClosure1.kt");
|
||||||
@@ -912,6 +927,11 @@ public class CodeMoverTestGenerated extends AbstractCodeMoverTest {
|
|||||||
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/outOfNestedClosure2.kt");
|
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/outOfNestedClosure2.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("outOfNestedClosureWithParams1.kt")
|
||||||
|
public void testOutOfNestedClosureWithParams1() throws Exception {
|
||||||
|
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/outOfNestedClosureWithParams1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("when1.kt")
|
@TestMetadata("when1.kt")
|
||||||
public void testWhen1() throws Exception {
|
public void testWhen1() throws Exception {
|
||||||
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/when1.kt");
|
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/when1.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user