CreateExpectActualFix: fix package for files with root package from non-root directory

#KT-28746 Fixed
This commit is contained in:
Dmitry Gridin
2019-07-17 15:48:55 +03:00
parent c76ca988eb
commit 4e2989e884
8 changed files with 29 additions and 1 deletions
@@ -68,7 +68,7 @@ abstract class AbstractCreateDeclarationFix<D : KtNamedDeclaration>(
val packageDirective = originalFile.packageDirective
if (packageDirective != null) {
val oldPackageDirective = targetFile.packageDirective
val newPackageDirective = factory.createPackageDirective(packageDirective.fqName)
val newPackageDirective = packageDirective.copy() as KtPackageDirective
if (oldPackageDirective != null) {
oldPackageDirective.replace(newPackageDirective)
} else {
@@ -0,0 +1,4 @@
// "Create actual class for module testModule_JVM (JVM)" "true"
// DISABLE-ERRORS
expect class <caret>My
@@ -0,0 +1,4 @@
// "Create actual class for module testModule_JVM (JVM)" "true"
// DISABLE-ERRORS
expect class My
@@ -0,0 +1 @@
actual class My
@@ -0,0 +1 @@
expect class `My.kt.after`
@@ -0,0 +1,4 @@
// "Create expected class in common module testModule_Common" "true"
// DISABLE-ERRORS
actual class <caret>My
@@ -0,0 +1,4 @@
// "Create expected class in common module testModule_Common" "true"
// DISABLE-ERRORS
actual class My
@@ -204,6 +204,11 @@ public class QuickFixMultiModuleTestGenerated extends AbstractQuickFixMultiModul
runTest("idea/testData/multiModuleQuickFix/convertPropertyToFunction/");
}
@TestMetadata("createActualWithRootPackage")
public void testCreateActualWithRootPackage() throws Exception {
runTest("idea/testData/multiModuleQuickFix/createActualWithRootPackage/");
}
@TestMetadata("createClassFromUsageImport")
public void testCreateClassFromUsageImport() throws Exception {
runTest("idea/testData/multiModuleQuickFix/createClassFromUsageImport/");
@@ -214,6 +219,11 @@ public class QuickFixMultiModuleTestGenerated extends AbstractQuickFixMultiModul
runTest("idea/testData/multiModuleQuickFix/createClassFromUsageRef/");
}
@TestMetadata("createExpectWithRootPackage")
public void testCreateExpectWithRootPackage() throws Exception {
runTest("idea/testData/multiModuleQuickFix/createExpectWithRootPackage/");
}
@TestMetadata("createFunInExpectClass")
public void testCreateFunInExpectClass() throws Exception {
runTest("idea/testData/multiModuleQuickFix/createFunInExpectClass/");