From 8a595ad1654a6fe889cc6017db059383e75af940 Mon Sep 17 00:00:00 2001 From: Toshiaki Kameyama Date: Mon, 5 Aug 2019 19:18:34 +0900 Subject: [PATCH] Move statement: Add or remove empty lines correctly #KT-14946 Fixed --- .../upDownMover/KotlinDeclarationMover.java | 61 +++++++++++++++---- .../class/classAtBrace1.kt.after | 1 + .../class/classAtBrace2.kt.after | 1 + .../class/classAtBrace3.kt.after | 1 + .../class/classAtBrace4.kt.after | 1 + .../class/classAtBrace5.kt.after | 1 + .../class/classAtBrace6.kt.after | 1 + .../class/classWithoutBody1.kt.after | 1 - .../class/classWithoutBody2.kt.after | 1 - .../class/classWithoutBody3.kt.after | 1 - .../class/classWithoutBody4.kt.after | 1 - .../classBodyDeclarations/class/kt-14946-1.kt | 10 +++ .../class/kt-14946-1.kt.after | 9 +++ .../classBodyDeclarations/class/kt-14946-2.kt | 9 +++ .../class/kt-14946-2.kt.after | 9 +++ .../classBodyDeclarations/class/kt-14946-3.kt | 9 +++ .../class/kt-14946-3.kt.after | 10 +++ .../classBodyDeclarations/class/kt-14946-4.kt | 10 +++ .../class/kt-14946-4.kt.after | 9 +++ .../classBodyDeclarations/class/kt-14946-5.kt | 9 +++ .../class/kt-14946-5.kt.after | 9 +++ .../classBodyDeclarations/class/kt-14946-6.kt | 9 +++ .../class/kt-14946-6.kt.after | 10 +++ .../classBodyDeclarations/class/kt-14946-7.kt | 9 +++ .../class/kt-14946-7.kt.after | 10 +++ .../function/functionAtBrace1.kt.after | 1 + .../function/functionAtBrace2.kt.after | 1 + .../function/functionAtBrace3.kt.after | 1 + .../function/functionAtBrace4.kt.after | 1 + .../function/functionAtBrace5.kt.after | 1 + .../function/functionAtBrace6.kt.after | 1 + .../property/propertyAtBrace1.kt.after | 1 + .../property/propertyAtBrace2.kt.after | 1 + .../property/propertyAtBrace3.kt.after | 1 + .../property/propertyAtBrace4.kt.after | 1 + .../property/propertyAtBrace5.kt.after | 1 + .../property/propertyAtBrace6.kt.after | 1 + .../MoveStatementTestGenerated.java | 35 +++++++++++ 38 files changed, 232 insertions(+), 17 deletions(-) create mode 100644 idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-1.kt create mode 100644 idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-1.kt.after create mode 100644 idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-2.kt create mode 100644 idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-2.kt.after create mode 100644 idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-3.kt create mode 100644 idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-3.kt.after create mode 100644 idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-4.kt create mode 100644 idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-4.kt.after create mode 100644 idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-5.kt create mode 100644 idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-5.kt.after create mode 100644 idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-6.kt create mode 100644 idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-6.kt.after create mode 100644 idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-7.kt create mode 100644 idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-7.kt.after diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/upDownMover/KotlinDeclarationMover.java b/idea/src/org/jetbrains/kotlin/idea/codeInsight/upDownMover/KotlinDeclarationMover.java index d9f17f6d070..f9dfb2780e9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/upDownMover/KotlinDeclarationMover.java +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/upDownMover/KotlinDeclarationMover.java @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.idea.codeInsight.upDownMover; import com.intellij.codeInsight.editorActions.moveUpDown.LineRange; +import com.intellij.openapi.editor.CaretModel; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.util.Pair; @@ -36,6 +37,8 @@ import java.util.List; public class KotlinDeclarationMover extends AbstractKotlinUpDownMover { private boolean moveEnumConstant = false; + private boolean moveOutOfBlock = false; + private boolean moveIntoBlock = false; private static int findNearestNonWhitespace(@NotNull CharSequence sequence, int index) { char ch = sequence.charAt(--index); @@ -48,8 +51,8 @@ public class KotlinDeclarationMover extends AbstractKotlinUpDownMover { @Override public void afterMove(@NotNull Editor editor, @NotNull PsiFile file, @NotNull MoveInfo info, boolean down) { super.afterMove(editor, file, info, down); + Document document = editor.getDocument(); if (moveEnumConstant) { - Document document = editor.getDocument(); CharSequence cs = document.getCharsSequence(); int end1 = findNearestNonWhitespace(cs, info.range1.getEndOffset()); char c1 = cs.charAt(end1); @@ -72,6 +75,27 @@ public class KotlinDeclarationMover extends AbstractKotlinUpDownMover { document.insertString(end1 + 1, ","); } } + if (moveIntoBlock || moveOutOfBlock) { + if (down) { + if (moveIntoBlock) { + document.deleteString(info.range1.getEndOffset(), info.range2.getStartOffset()); + } + else { + int offset = info.range1.getEndOffset(); + document.insertString(offset, "\n"); + CaretModel caretModel = editor.getCaretModel(); + if (document.getCharsSequence().charAt(caretModel.getOffset() - 1) == '\n') caretModel.moveToOffset(offset + 1); + } + } + else { + if (moveIntoBlock) { + document.deleteString(info.range2.getEndOffset(), info.range1.getStartOffset()); + } + else { + document.insertString(info.range2.getEndOffset(), "\n"); + } + } + } } @NotNull @@ -228,7 +252,7 @@ public class KotlinDeclarationMover extends AbstractKotlinUpDownMover { PsiElement nextParent = null; // moving out of code block - if (sibling.getNode().getElementType() == (down ? KtTokens.RBRACE : KtTokens.LBRACE)) { + if (isMovingOutOfBlock(sibling, down)) { // elements which aren't immediately placed in class body can't leave the block PsiElement parent = sibling.getParent(); if (!(parent instanceof KtClassBody)) return null; @@ -246,18 +270,14 @@ public class KotlinDeclarationMover extends AbstractKotlinUpDownMover { // moving into code block // element may move only into class body else { - if (sibling instanceof KtClassOrObject) { - KtClassOrObject ktClassOrObject = (KtClassOrObject) sibling; - KtClassBody classBody = ktClassOrObject.getBody(); - - // confined elements can't leave their block - if (classBody != null) { - nextParent = classBody; - if (!down) { - start = classBody.getRBrace(); - } - end = down ? classBody.getLBrace() : classBody.getRBrace(); + KtClassBody classBody = getClassBody(sibling); + // confined elements can't leave their block + if (classBody != null) { + nextParent = classBody; + if (!down) { + start = classBody.getRBrace(); } + end = down ? classBody.getLBrace() : classBody.getRBrace(); } } @@ -279,6 +299,19 @@ public class KotlinDeclarationMover extends AbstractKotlinUpDownMover { return start != null && end != null ? new LineRange(start, end, editor.getDocument()) : null; } + private static boolean isMovingOutOfBlock(@NotNull PsiElement sibling, boolean down) { + return sibling.getNode().getElementType() == (down ? KtTokens.RBRACE : KtTokens.LBRACE); + } + + @Nullable + private static KtClassBody getClassBody(PsiElement element) { + if (element instanceof KtClassOrObject) { + return ((KtClassOrObject) element).getBody(); + } else { + return null; + } + } + @Override public boolean checkAvailable(@NotNull Editor editor, @NotNull PsiFile file, @NotNull MoveInfo info, boolean down) { if (!super.checkAvailable(editor, file, info, down)) return false; @@ -306,6 +339,8 @@ public class KotlinDeclarationMover extends AbstractKotlinUpDownMover { info.toMove2 = null; return true; } + moveOutOfBlock = isMovingOutOfBlock(sibling, down); + moveIntoBlock = getClassBody(sibling) != null; info.toMove = sourceRange; info.toMove2 = getTargetRange(editor, sibling, down, sourceRange.firstElement); diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace1.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace1.kt.after index 09877092920..c0b38465245 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace1.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace1.kt.after @@ -5,6 +5,7 @@ class A { val x = "" } + // class B class B { diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace2.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace2.kt.after index d75c20f3229..5e73f9e4be3 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace2.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace2.kt.after @@ -2,6 +2,7 @@ class B { } + // MOVE: up // class A class A { diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace3.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace3.kt.after index 429bb73b84b..936a9ed7de3 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace3.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace3.kt.after @@ -4,6 +4,7 @@ class A { // class B class B { } + // class C class C { diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace4.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace4.kt.after index 4d6d84089c1..58df71b7fea 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace4.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace4.kt.after @@ -5,6 +5,7 @@ class A { class C { } + // class B class B { } diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace5.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace5.kt.after index 6e16eb2f678..85d1b5bbabb 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace5.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace5.kt.after @@ -4,6 +4,7 @@ fun foo() { // class A class A { } + // class B class B { diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace6.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace6.kt.after index bb4a9a8d486..05411f3c93a 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace6.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtBrace6.kt.after @@ -5,6 +5,7 @@ fun foo() { class B { } + // class A class A { } diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classWithoutBody1.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classWithoutBody1.kt.after index 10ffd3ec439..64ab0ea9974 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classWithoutBody1.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classWithoutBody1.kt.after @@ -1,6 +1,5 @@ // class D class D { - // MOVE: down // class A class A diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classWithoutBody2.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classWithoutBody2.kt.after index bfe6cf554e7..cda1d1742d4 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classWithoutBody2.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classWithoutBody2.kt.after @@ -3,7 +3,6 @@ class D { // class A class A - } // class C diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classWithoutBody3.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classWithoutBody3.kt.after index 77b59e552e5..82650bfbbe7 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classWithoutBody3.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classWithoutBody3.kt.after @@ -1,6 +1,5 @@ // class D class D { - // MOVE: down // class A class A diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classWithoutBody4.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classWithoutBody4.kt.after index 60afa7518cf..171fddff92e 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classWithoutBody4.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classWithoutBody4.kt.after @@ -3,5 +3,4 @@ class D { // class A class A - } diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-1.kt b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-1.kt new file mode 100644 index 00000000000..ab88a57912b --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-1.kt @@ -0,0 +1,10 @@ +// MOVE: down +class Outer { + class N1 { + fun foo1() {} + } + + class N2 { + fun foo2() {} + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-1.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-1.kt.after new file mode 100644 index 00000000000..0a3c0e1e553 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-1.kt.after @@ -0,0 +1,9 @@ +// MOVE: down +class Outer { + class N2 { + class N1 { + fun foo1() {} + } + fun foo2() {} + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-2.kt b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-2.kt new file mode 100644 index 00000000000..0a3c0e1e553 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-2.kt @@ -0,0 +1,9 @@ +// MOVE: down +class Outer { + class N2 { + class N1 { + fun foo1() {} + } + fun foo2() {} + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-2.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-2.kt.after new file mode 100644 index 00000000000..5624247f4cb --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-2.kt.after @@ -0,0 +1,9 @@ +// MOVE: down +class Outer { + class N2 { + fun foo2() {} + class N1 { + fun foo1() {} + } + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-3.kt b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-3.kt new file mode 100644 index 00000000000..5624247f4cb --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-3.kt @@ -0,0 +1,9 @@ +// MOVE: down +class Outer { + class N2 { + fun foo2() {} + class N1 { + fun foo1() {} + } + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-3.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-3.kt.after new file mode 100644 index 00000000000..c1bac9bfcb9 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-3.kt.after @@ -0,0 +1,10 @@ +// MOVE: down +class Outer { + class N2 { + fun foo2() {} + } + + class N1 { + fun foo1() {} + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-4.kt b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-4.kt new file mode 100644 index 00000000000..96ed5c13494 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-4.kt @@ -0,0 +1,10 @@ +// MOVE: up +class Outer { + class N2 { + fun foo2() {} + } + + class N1 { + fun foo1() {} + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-4.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-4.kt.after new file mode 100644 index 00000000000..d66343f79e5 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-4.kt.after @@ -0,0 +1,9 @@ +// MOVE: up +class Outer { + class N2 { + fun foo2() {} + class N1 { + fun foo1() {} + } + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-5.kt b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-5.kt new file mode 100644 index 00000000000..d66343f79e5 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-5.kt @@ -0,0 +1,9 @@ +// MOVE: up +class Outer { + class N2 { + fun foo2() {} + class N1 { + fun foo1() {} + } + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-5.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-5.kt.after new file mode 100644 index 00000000000..b6d2f886b8a --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-5.kt.after @@ -0,0 +1,9 @@ +// MOVE: up +class Outer { + class N2 { + class N1 { + fun foo1() {} + } + fun foo2() {} + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-6.kt b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-6.kt new file mode 100644 index 00000000000..b6d2f886b8a --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-6.kt @@ -0,0 +1,9 @@ +// MOVE: up +class Outer { + class N2 { + class N1 { + fun foo1() {} + } + fun foo2() {} + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-6.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-6.kt.after new file mode 100644 index 00000000000..5723f728440 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-6.kt.after @@ -0,0 +1,10 @@ +// MOVE: up +class Outer { + class N1 { + fun foo1() {} + } + + class N2 { + fun foo2() {} + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-7.kt b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-7.kt new file mode 100644 index 00000000000..99cb0154c80 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-7.kt @@ -0,0 +1,9 @@ +// MOVE: down +class Outer { + class N2 { + fun foo2() {} + class N1 { + fun foo1() {} + } + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-7.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-7.kt.after new file mode 100644 index 00000000000..5457926bb0b --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-7.kt.after @@ -0,0 +1,10 @@ +// MOVE: down +class Outer { + class N2 { + fun foo2() {} + } + + class N1 { + fun foo1() {} + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace1.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace1.kt.after index 17d03765f7e..dcd140f9d19 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace1.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace1.kt.after @@ -5,6 +5,7 @@ class A { val x = "" } + // fun foo fun foo() { diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace2.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace2.kt.after index 239d20845d4..01a7bd709ee 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace2.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace2.kt.after @@ -2,6 +2,7 @@ fun foo() { } + // MOVE: up // class A class A { diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace3.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace3.kt.after index 6dcf5eec653..c4553fb5f3b 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace3.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace3.kt.after @@ -4,6 +4,7 @@ class A { // class B class B { } + // fun foo fun foo() { diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace4.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace4.kt.after index 21ff689525c..314a5c1bbdd 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace4.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace4.kt.after @@ -5,6 +5,7 @@ class A { fun foo() { } + // class B class B { } diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace5.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace5.kt.after index 74ff1b4b6f0..2a275f994a1 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace5.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace5.kt.after @@ -4,6 +4,7 @@ fun foo() { // class B class B { } + // fun foo fun foo() { diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace6.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace6.kt.after index 097015b4e70..5f2e0df71c6 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace6.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/function/functionAtBrace6.kt.after @@ -5,6 +5,7 @@ fun foo() { fun foo() { } + // class B class B { } diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace1.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace1.kt.after index 8b140d7e844..ebe89189c7c 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace1.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace1.kt.after @@ -5,5 +5,6 @@ class A { val x = "" } + // val y val y = "" diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace2.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace2.kt.after index 0882314d8f8..3079264a915 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace2.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace2.kt.after @@ -1,5 +1,6 @@ // val x val x = "" + // MOVE: up // class A class A { diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace3.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace3.kt.after index bece750599c..87f059f3053 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace3.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace3.kt.after @@ -4,6 +4,7 @@ class A { // class B class B { } + // val y val y = "" } \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace4.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace4.kt.after index 6aec8bf7a81..d62441a768b 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace4.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace4.kt.after @@ -3,6 +3,7 @@ class A { // val y val y = "" + // class B class B { } diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace5.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace5.kt.after index f5865f313bb..e8c3267c1a5 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace5.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace5.kt.after @@ -4,6 +4,7 @@ fun foo() { // class B class B { } + // val y val y = "" } \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace6.kt.after b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace6.kt.after index 5db241f256f..243f549f25a 100644 --- a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace6.kt.after +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/property/propertyAtBrace6.kt.after @@ -3,6 +3,7 @@ fun foo() { // val y val y = "" + // class B class B { } diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/moveUpDown/MoveStatementTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/moveUpDown/MoveStatementTestGenerated.java index 87ad0a4d417..5680aa2905f 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/moveUpDown/MoveStatementTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/moveUpDown/MoveStatementTestGenerated.java @@ -194,6 +194,41 @@ public class MoveStatementTestGenerated extends AbstractMoveStatementTest { public void testClassWithoutBody4() throws Exception { runTest("idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classWithoutBody4.kt"); } + + @TestMetadata("kt-14946-1.kt") + public void testKt_14946_1() throws Exception { + runTest("idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-1.kt"); + } + + @TestMetadata("kt-14946-2.kt") + public void testKt_14946_2() throws Exception { + runTest("idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-2.kt"); + } + + @TestMetadata("kt-14946-3.kt") + public void testKt_14946_3() throws Exception { + runTest("idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-3.kt"); + } + + @TestMetadata("kt-14946-4.kt") + public void testKt_14946_4() throws Exception { + runTest("idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-4.kt"); + } + + @TestMetadata("kt-14946-5.kt") + public void testKt_14946_5() throws Exception { + runTest("idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-5.kt"); + } + + @TestMetadata("kt-14946-6.kt") + public void testKt_14946_6() throws Exception { + runTest("idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-6.kt"); + } + + @TestMetadata("kt-14946-7.kt") + public void testKt_14946_7() throws Exception { + runTest("idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/kt-14946-7.kt"); + } } @TestMetadata("idea/testData/codeInsight/moveUpDown/classBodyDeclarations/classInitializer")