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 498eae72b03..b7e563ba0c9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/upDownMover/KotlinDeclarationMover.java +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/upDownMover/KotlinDeclarationMover.java @@ -292,8 +292,7 @@ public class KotlinDeclarationMover extends AbstractKotlinUpDownMover { PsiElement sibling = getLastNonWhiteSiblingInLine(firstNonWhiteSibling(sourceRange, down), editor, down); - // Either reached last sibling, or jumped over multi-line whitespace - if (sibling == null) { + if (sibling == null || sibling instanceof KtPackageDirective || sibling instanceof KtImportList) { info.toMove2 = null; return true; } diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtImport.kt b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtImport.kt new file mode 100644 index 00000000000..42e8de7a2d9 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtImport.kt @@ -0,0 +1,5 @@ +// MOVE: up +// IS_APPLICABLE: false +import foo.Bar + +class A diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtImportInScript.kts b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtImportInScript.kts new file mode 100644 index 00000000000..42e8de7a2d9 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtImportInScript.kts @@ -0,0 +1,5 @@ +// MOVE: up +// IS_APPLICABLE: false +import foo.Bar + +class A diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtPackage.kt b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtPackage.kt new file mode 100644 index 00000000000..32caeb5fc5b --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtPackage.kt @@ -0,0 +1,5 @@ +// MOVE: up +// IS_APPLICABLE: false +package foo.bar + +class A diff --git a/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtPackageInScript.kts b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtPackageInScript.kts new file mode 100644 index 00000000000..32caeb5fc5b --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtPackageInScript.kts @@ -0,0 +1,5 @@ +// MOVE: up +// IS_APPLICABLE: false +package foo.bar + +class A 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 591f7c18302..39a57f887b6 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/moveUpDown/MoveStatementTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/moveUpDown/MoveStatementTestGenerated.java @@ -145,6 +145,26 @@ public class MoveStatementTestGenerated extends AbstractMoveStatementTest { runTest("idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtFunction2.kt"); } + @TestMetadata("classAtImport.kt") + public void testClassAtImport() throws Exception { + runTest("idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtImport.kt"); + } + + @TestMetadata("classAtImportInScript.kts") + public void testClassAtImportInScript() throws Exception { + runTest("idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtImportInScript.kts"); + } + + @TestMetadata("classAtPackage.kt") + public void testClassAtPackage() throws Exception { + runTest("idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtPackage.kt"); + } + + @TestMetadata("classAtPackageInScript.kts") + public void testClassAtPackageInScript() throws Exception { + runTest("idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtPackageInScript.kts"); + } + @TestMetadata("classAtProperty1.kt") public void testClassAtProperty1() throws Exception { runTest("idea/testData/codeInsight/moveUpDown/classBodyDeclarations/class/classAtProperty1.kt");