KT-3736 Fixed: "Move Statement Down doesn't work to improperly formatted code"

This commit is contained in:
Alexey Sedunov
2013-07-10 14:37:57 +04:00
parent 4f6d09eaba
commit 6e513f067f
6 changed files with 46 additions and 2 deletions
@@ -47,9 +47,15 @@ public abstract class AbstractJetUpDownMover extends LineMover {
LineRange lineRange2 = getElementSourceLineRange(combinedRange.second, editor, oldRange);
if (lineRange2 == null) return null;
LineRange parentLineRange = getElementSourceLineRange(parent, editor, oldRange);
LineRange sourceRange = new LineRange(lineRange1.startLine, lineRange2.endLine);
sourceRange.firstElement = combinedRange.first;
sourceRange.lastElement = combinedRange.second;
if (parentLineRange != null && sourceRange.contains(parentLineRange)) {
sourceRange.firstElement = sourceRange.lastElement = parent;
} else {
sourceRange.firstElement = combinedRange.first;
sourceRange.lastElement = combinedRange.second;
}
return sourceRange;
}
@@ -0,0 +1,7 @@
// MOVE: down
fun main(args: Array<String>) {
<caret>run {
println()
}
}
@@ -0,0 +1,7 @@
// MOVE: down
fun main(args: Array<String>) {
<caret>run {
println()
}
}
@@ -0,0 +1,7 @@
// MOVE: up
fun main(args: Array<String>) {
<caret>run {
println()
}
}
@@ -0,0 +1,7 @@
// MOVE: up
fun main(args: Array<String>) {
<caret>run {
println()
}
}
@@ -817,6 +817,16 @@ public class CodeMoverTestGenerated extends AbstractCodeMoverTest {
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/closureInWhile2.kt");
}
@TestMetadata("closureWthoutSpaces1.kt")
public void testClosureWthoutSpaces1() throws Exception {
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/closureWthoutSpaces1.kt");
}
@TestMetadata("closureWthoutSpaces2.kt")
public void testClosureWthoutSpaces2() throws Exception {
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/closureWthoutSpaces2.kt");
}
@TestMetadata("declaration1.kt")
public void testDeclaration1() throws Exception {
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/declaration1.kt");