Move statement: enable expression ended with semicolon (KT-8581)
#KT-8581 Fixed
This commit is contained in:
committed by
Nikolay Krasko
parent
5259af157a
commit
7b8abc5457
+5
-1
@@ -411,7 +411,7 @@ public class KotlinExpressionMover extends AbstractKotlinUpDownMover {
|
||||
|
||||
@Override
|
||||
protected boolean checkSourceElement(@NotNull PsiElement element) {
|
||||
return PsiTreeUtil.instanceOf(element, MOVABLE_ELEMENT_CLASSES);
|
||||
return PsiTreeUtil.instanceOf(element, MOVABLE_ELEMENT_CLASSES) || element.getNode().getElementType() == KtTokens.SEMICOLON;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -427,6 +427,10 @@ public class KotlinExpressionMover extends AbstractKotlinUpDownMover {
|
||||
|
||||
@Nullable
|
||||
private static PsiElement getMovableElement(@NotNull PsiElement element, boolean lookRight) {
|
||||
if (element.getNode().getElementType() == KtTokens.SEMICOLON) {
|
||||
return element;
|
||||
}
|
||||
|
||||
//noinspection unchecked
|
||||
PsiElement movableElement = PsiUtilsKt.getParentOfTypesAndPredicate(
|
||||
element,
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// MOVE: up
|
||||
fun x() {
|
||||
println("a")
|
||||
<caret>println("b");
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// MOVE: up
|
||||
fun x() {
|
||||
<caret>println("b");
|
||||
println("a")
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// MOVE: down
|
||||
fun x() {
|
||||
<caret>println("b");
|
||||
println("a")
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// MOVE: down
|
||||
fun x() {
|
||||
println("a")
|
||||
<caret>println("b");
|
||||
}
|
||||
Generated
+10
@@ -1109,6 +1109,16 @@ public class MoveStatementTestGenerated extends AbstractMoveStatementTest {
|
||||
runTest("idea/testData/codeInsight/moveUpDown/expressions/qualifiedCall2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("semicolon1.kt")
|
||||
public void testSemicolon1() throws Exception {
|
||||
runTest("idea/testData/codeInsight/moveUpDown/expressions/semicolon1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("semicolon2.kt")
|
||||
public void testSemicolon2() throws Exception {
|
||||
runTest("idea/testData/codeInsight/moveUpDown/expressions/semicolon2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("when1.kt")
|
||||
public void testWhen1() throws Exception {
|
||||
runTest("idea/testData/codeInsight/moveUpDown/expressions/when1.kt");
|
||||
|
||||
Reference in New Issue
Block a user