[kotlin] move statements: take care of error elements

^KTIJ-31312 fixed

GitOrigin-RevId: 1de2219e328f0c7ac38816a1f468556a061cd932
This commit is contained in:
Anna Kozlova
2024-09-17 12:02:34 +00:00
committed by intellij-monorepo-bot
parent d67c2fc0a3
commit 5d2db4e7e8
5 changed files with 30 additions and 0 deletions
@@ -504,6 +504,10 @@ class KotlinExpressionMover : AbstractKotlinUpDownMover() {
return element
}
if (element is PsiErrorElement) {
return element
}
if (getParentFileAnnotationEntry(element) != null) return null
val movableElement = element.getParentOfTypesAndPredicate(
@@ -1385,6 +1385,11 @@ public abstract class KotlinFirMoveStatementTestGenerated extends AbstractKotlin
KotlinTestUtils.runTest(this::doTestLine, this, testDataFilePath);
}
@TestMetadata("additionalClosingBrace.kt")
public void testAdditionalClosingBrace() throws Exception {
runTest("../../idea/tests/testData/codeInsight/moveUpDown/line/additionalClosingBrace.kt");
}
@TestMetadata("fileAnnotation.kt")
public void testFileAnnotation() throws Exception {
runTest("../../idea/tests/testData/codeInsight/moveUpDown/line/fileAnnotation.kt");
@@ -1385,6 +1385,11 @@ public abstract class MoveStatementTestGenerated extends AbstractMoveStatementTe
KotlinTestUtils.runTest(this::doTestLine, this, testDataFilePath);
}
@TestMetadata("additionalClosingBrace.kt")
public void testAdditionalClosingBrace() throws Exception {
runTest("testData/codeInsight/moveUpDown/line/additionalClosingBrace.kt");
}
@TestMetadata("fileAnnotation.kt")
public void testFileAnnotation() throws Exception {
runTest("testData/codeInsight/moveUpDown/line/fileAnnotation.kt");
@@ -0,0 +1,8 @@
// MOVE: up
fun dispose(editor: Editor) {
val disposable = editor.getUserData(AIDiffKeys.AI_DIFF_VIEWER) as AIInEditorDiffViewer?
if (disposable != null) {
}
Disposer.dispose(disposable))<caret>
}
@@ -0,0 +1,8 @@
// MOVE: up
fun dispose(editor: Editor) {
val disposable = editor.getUserData(AIDiffKeys.AI_DIFF_VIEWER) as AIInEditorDiffViewer?
if (disposable != null) {
Disposer.dispose(disposable))<selection><caret></selection>
}
}