Move statement: don't move declarations above package and import directives
This commit is contained in:
committed by
Natalia Selezneva
parent
742c3a228a
commit
bfa6c7d399
+1
-2
@@ -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;
|
||||
}
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// MOVE: up
|
||||
// IS_APPLICABLE: false
|
||||
import foo.Bar
|
||||
|
||||
<caret>class A
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// MOVE: up
|
||||
// IS_APPLICABLE: false
|
||||
import foo.Bar
|
||||
|
||||
<caret>class A
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// MOVE: up
|
||||
// IS_APPLICABLE: false
|
||||
package foo.bar
|
||||
|
||||
<caret>class A
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
// MOVE: up
|
||||
// IS_APPLICABLE: false
|
||||
package foo.bar
|
||||
|
||||
<caret>class A
|
||||
Generated
+20
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user