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) {
|
||||
if (fqName.isRoot()) {
|
||||
delete();
|
||||
if (!getFqName().isRoot()) {
|
||||
//noinspection ConstantConditions
|
||||
replace(new KtPsiFactory(getProject()).createFile("").getPackageDirective());
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
@TestMetadata("copyFileFromDefaultPackageToDefaultPackage/copyFIleToDefaultPackage.test")
|
||||
public void testCopyFileFromDefaultPackageToDefaultPackage_CopyFIleToDefaultPackage() throws Exception {
|
||||
runTest("idea/testData/refactoring/copy/copyFileFromDefaultPackageToDefaultPackage/copyFIleToDefaultPackage.test");
|
||||
}
|
||||
|
||||
@TestMetadata("copyFIleRetainContent/copyFIleRetainContent.test")
|
||||
public void testCopyFIleRetainContent_CopyFIleRetainContent() throws Exception {
|
||||
runTest("idea/testData/refactoring/copy/copyFIleRetainContent/copyFIleRetainContent.test");
|
||||
|
||||
Reference in New Issue
Block a user