PSI: Do not delete package directive for file in default package
#KT-24968 Fixed
This commit is contained in:
@@ -119,7 +119,10 @@ public class KtPackageDirective extends KtModifierListOwnerStub<KotlinPlaceHolde
|
|||||||
|
|
||||||
public void setFqName(@NotNull FqName fqName) {
|
public void setFqName(@NotNull FqName fqName) {
|
||||||
if (fqName.isRoot()) {
|
if (fqName.isRoot()) {
|
||||||
delete();
|
if (!getFqName().isRoot()) {
|
||||||
|
//noinspection ConstantConditions
|
||||||
|
replace(new KtPsiFactory(getProject()).createFile("").getPackageDirective());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
val a = 42
|
||||||
|
|
||||||
|
// comment
|
||||||
|
|
||||||
|
// some other comment
|
||||||
|
val s = ""
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
val a = 42
|
||||||
|
|
||||||
|
// comment
|
||||||
|
|
||||||
|
// some other comment
|
||||||
|
val s = ""
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
val a = 42
|
||||||
|
|
||||||
|
// comment
|
||||||
|
|
||||||
|
// some other comment
|
||||||
|
val s = ""
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"mainFile": "test.kt",
|
||||||
|
"targetPackage": "",
|
||||||
|
"newName": "test2.kt"
|
||||||
|
}
|
||||||
@@ -64,6 +64,11 @@ public class CopyTestGenerated extends AbstractCopyTest {
|
|||||||
runTest("idea/testData/refactoring/copy/copyFIleFromDefaultPackage/copyFIleFromDefaultPackage.test");
|
runTest("idea/testData/refactoring/copy/copyFIleFromDefaultPackage/copyFIleFromDefaultPackage.test");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("copyFileFromDefaultPackageToDefaultPackage/copyFIleToDefaultPackage.test")
|
||||||
|
public void testCopyFileFromDefaultPackageToDefaultPackage_CopyFIleToDefaultPackage() throws Exception {
|
||||||
|
runTest("idea/testData/refactoring/copy/copyFileFromDefaultPackageToDefaultPackage/copyFIleToDefaultPackage.test");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("copyFIleRetainContent/copyFIleRetainContent.test")
|
@TestMetadata("copyFIleRetainContent/copyFIleRetainContent.test")
|
||||||
public void testCopyFIleRetainContent_CopyFIleRetainContent() throws Exception {
|
public void testCopyFIleRetainContent_CopyFIleRetainContent() throws Exception {
|
||||||
runTest("idea/testData/refactoring/copy/copyFIleRetainContent/copyFIleRetainContent.test");
|
runTest("idea/testData/refactoring/copy/copyFIleRetainContent/copyFIleRetainContent.test");
|
||||||
|
|||||||
Reference in New Issue
Block a user