Add tests for Java "Move File" refactoring
This commit is contained in:
+7
@@ -0,0 +1,7 @@
|
||||
package a
|
||||
|
||||
import b.A
|
||||
|
||||
fun bar() {
|
||||
val t: A = A()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package a
|
||||
|
||||
import b.*
|
||||
|
||||
fun bar() {
|
||||
val t: A = A()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package a
|
||||
|
||||
import b.A as X
|
||||
|
||||
fun bar() {
|
||||
val t: X = X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package b;
|
||||
|
||||
public class A {
|
||||
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package b;
|
||||
|
||||
public class B {
|
||||
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package b
|
||||
|
||||
fun bar() {
|
||||
val t: A = A()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package b
|
||||
|
||||
import a.*
|
||||
|
||||
fun bar() {
|
||||
val t: A = A()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package b
|
||||
|
||||
import b.A as X
|
||||
|
||||
fun bar() {
|
||||
val t: X = X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package a;
|
||||
|
||||
public class A {
|
||||
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package a
|
||||
|
||||
fun bar() {
|
||||
val t: A = A()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package a
|
||||
|
||||
import b.*
|
||||
|
||||
fun bar() {
|
||||
val t: A = A()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package a
|
||||
|
||||
import a.A as X
|
||||
|
||||
fun bar() {
|
||||
val t: X = X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package b;
|
||||
|
||||
public class B {
|
||||
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package b
|
||||
|
||||
fun bar() {
|
||||
val t: a.A = a.A()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package b
|
||||
|
||||
import a.*
|
||||
|
||||
fun bar() {
|
||||
val t: A = A()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package b
|
||||
|
||||
import a.A as X
|
||||
|
||||
fun bar() {
|
||||
val t: X = X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"mainFile": "a/main.java",
|
||||
"type": "MOVE_FILES",
|
||||
"targetPackage": "b"
|
||||
}
|
||||
@@ -47,6 +47,7 @@ import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.refactoring.move.moveClassesOrPackages.MoveClassToInnerProcessor
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectoriesProcessor
|
||||
|
||||
public abstract class AbstractJetMoveTest : MultiFileTestCase() {
|
||||
protected fun doTest(path: String) {
|
||||
@@ -223,5 +224,22 @@ enum class MoveAction {
|
||||
}
|
||||
}
|
||||
|
||||
MOVE_FILES {
|
||||
override fun runRefactoring(mainFile: PsiFile, elementAtCaret: PsiElement?, config: JsonObject) {
|
||||
val project = mainFile.getProject()
|
||||
val targetPackage = config.getString("targetPackage")
|
||||
|
||||
MoveFilesOrDirectoriesProcessor(
|
||||
project = project,
|
||||
elements = array(mainFile),
|
||||
newParent = JavaPsiFacade.getInstance(project).findPackage(targetPackage)!!.getDirectories()[0],
|
||||
searchInComments = false,
|
||||
searchInNonJavaFiles = true,
|
||||
moveCallback = null,
|
||||
prepareSuccessfulCallback = null
|
||||
).run()
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun runRefactoring(mainFile: PsiFile, elementAtCaret: PsiElement?, config: JsonObject)
|
||||
}
|
||||
|
||||
@@ -131,6 +131,11 @@ public class JetMoveTestGenerated extends AbstractJetMoveTest {
|
||||
doTest("idea/testData/refactoring/move/java/moveField/moveFieldToTopLevelClassOfAnotherPackage/moveFieldToTopLevelClassOfAnotherPackage.test");
|
||||
}
|
||||
|
||||
@TestMetadata("java/moveFile/moveFileToAnotherPackage/moveFileToAnotherPackage.test")
|
||||
public void testJava_moveFile_moveFileToAnotherPackage_MoveFileToAnotherPackage() throws Exception {
|
||||
doTest("idea/testData/refactoring/move/java/moveFile/moveFileToAnotherPackage/moveFileToAnotherPackage.test");
|
||||
}
|
||||
|
||||
@TestMetadata("java/moveMethod/moveMethodToExternalNestedClass/moveMethodToExternalNestedClass.test")
|
||||
public void testJava_moveMethod_moveMethodToExternalNestedClass_MoveMethodToExternalNestedClass() throws Exception {
|
||||
doTest("idea/testData/refactoring/move/java/moveMethod/moveMethodToExternalNestedClass/moveMethodToExternalNestedClass.test");
|
||||
|
||||
Reference in New Issue
Block a user