PSI: Do not delete package directive for file in default package

#KT-24968 Fixed
This commit is contained in:
Alexey Sedunov
2018-06-19 17:18:45 +03:00
parent e2a632e326
commit 60583e557f
6 changed files with 32 additions and 1 deletions
@@ -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;
}
@@ -0,0 +1,6 @@
val a = 42
// comment
// some other comment
val s = ""
@@ -0,0 +1,6 @@
val a = 42
// comment
// some other comment
val s = ""
@@ -0,0 +1,6 @@
val a = 42
// comment
// some other comment
val s = ""
@@ -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");