diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveHandlerDelegateCompat.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveHandlerDelegateCompat.kt new file mode 100644 index 00000000000..d6b580d72ab --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveHandlerDelegateCompat.kt @@ -0,0 +1,17 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.idea.refactoring.move + +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiReference +import com.intellij.refactoring.move.MoveHandlerDelegate + +// BUNCH: 191 +internal fun MoveHandlerDelegate.canMoveCompat( + elements: Array, + targetContainer: PsiElement?, + reference: PsiReference? +): Boolean = canMove(elements, targetContainer, reference) \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveHandlerDelegateCompat.kt.191 b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveHandlerDelegateCompat.kt.191 new file mode 100644 index 00000000000..af52939024c --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveHandlerDelegateCompat.kt.191 @@ -0,0 +1,17 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.idea.refactoring.move + +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiReference +import com.intellij.refactoring.move.MoveHandlerDelegate + +// BUNCH: 191 +internal fun MoveHandlerDelegate.canMoveCompat( + elements: Array, + targetContainer: PsiElement?, + reference: PsiReference? +): Boolean = canMove(elements, targetContainer) \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveKotlinDeclarationsHandlerTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveKotlinDeclarationsHandlerTest.kt index 2432ff12965..43e3d7e1928 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveKotlinDeclarationsHandlerTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveKotlinDeclarationsHandlerTest.kt @@ -51,90 +51,90 @@ class MoveKotlinDeclarationsHandlerTest : KotlinMultiFileTestCase() { fun testObjectLiteral() = doTest { rootDir, handler -> val objectDeclaration = getElementAtCaret(rootDir, "test.kt").getNonStrictParentOfType()!! - assert(!handler.canMove(arrayOf(objectDeclaration), null)) + assert(!handler.canMoveCompat(arrayOf(objectDeclaration), null, null)) } fun testLocalClass() = doTest { rootDir, handler -> val klass = getElementAtCaret(rootDir, "test.kt").getNonStrictParentOfType()!! - assert(!handler.canMove(arrayOf(klass), null)) + assert(!handler.canMoveCompat(arrayOf(klass), null, null)) } fun testLocalFun() = doTest { rootDir, handler -> val function = getElementAtCaret(rootDir, "test.kt").getNonStrictParentOfType()!! - assert(!handler.canMove(arrayOf(function), null)) + assert(!handler.canMoveCompat(arrayOf(function), null, null)) } fun testLocalVal() = doTest { rootDir, handler -> val property = getElementAtCaret(rootDir, "test.kt").getNonStrictParentOfType()!! - assert(!handler.canMove(arrayOf(property), null)) + assert(!handler.canMoveCompat(arrayOf(property), null, null)) } fun testMemberFun() = doTest { rootDir, handler -> val function = getElementAtCaret(rootDir, "test.kt").getNonStrictParentOfType()!! - assert(!handler.canMove(arrayOf(function), null)) + assert(!handler.canMoveCompat(arrayOf(function), null, null)) } fun testMemberVal() = doTest { rootDir, handler -> val property = getElementAtCaret(rootDir, "test.kt").getNonStrictParentOfType()!! - assert(!handler.canMove(arrayOf(property), null)) + assert(!handler.canMoveCompat(arrayOf(property), null, null)) } fun testNestedClass() = doTest { rootDir, handler -> val klass = getElementAtCaret(rootDir, "test.kt").getNonStrictParentOfType()!! - assert(handler.canMove(arrayOf(klass), null)) + assert(handler.canMoveCompat(arrayOf(klass), null, null)) } fun testInnerClass() = doTest { rootDir, handler -> val klass = getElementAtCaret(rootDir, "test.kt").getNonStrictParentOfType()!! - assert(handler.canMove(arrayOf(klass), null)) + assert(handler.canMoveCompat(arrayOf(klass), null, null)) } fun testTopLevelClass() = doTest { rootDir, handler -> val klass = getElementAtCaret(rootDir, "test.kt").getNonStrictParentOfType()!! - assert(handler.canMove(arrayOf(klass), null)) + assert(handler.canMoveCompat(arrayOf(klass), null, null)) } fun testTopLevelFun() = doTest { rootDir, handler -> val function = getElementAtCaret(rootDir, "test.kt").getNonStrictParentOfType()!! - assert(handler.canMove(arrayOf(function), null)) + assert(handler.canMoveCompat(arrayOf(function), null, null)) } fun testTopLevelVal() = doTest { rootDir, handler -> val property = getElementAtCaret(rootDir, "test.kt").getNonStrictParentOfType()!! - assert(handler.canMove(arrayOf(property), null)) + assert(handler.canMoveCompat(arrayOf(property), null, null)) } fun testMultipleNestedClasses() = doTest { rootDir, handler -> val classes = getElementsAtCarets(rootDir, "test.kt").map { it.getNonStrictParentOfType()!! } - assert(handler.canMove(classes.toTypedArray(), null)) + assert(handler.canMoveCompat(classes.toTypedArray(), null, null)) } fun testNestedAndTopLevelClass() = doTest { rootDir, handler -> val classes = getElementsAtCarets(rootDir, "test.kt").map { it.getNonStrictParentOfType()!! } - assert(!handler.canMove(classes.toTypedArray(), null)) + assert(!handler.canMoveCompat(classes.toTypedArray(), null, null)) } fun testMultipleTopLevelDeclarations() = doTest { rootDir, handler -> val declarations = getElementsAtCarets(rootDir, "test.kt").map { it.getNonStrictParentOfType()!! } - assert(handler.canMove(declarations.toTypedArray(), null)) + assert(handler.canMoveCompat(declarations.toTypedArray(), null, null)) } fun testMultipleTopLevelDeclarationsInDifferentFiles() = doTest { rootDir, handler -> val declarations = listOf("test.kt", "test2.kt").flatMap { getElementsAtCarets(rootDir, it) } .map { it.getNonStrictParentOfType()!! } - assert(handler.canMove(declarations.toTypedArray(), null)) + assert(handler.canMoveCompat(declarations.toTypedArray(), null, null)) val files = listOf("test.kt", "test2.kt").map { getPsiFile(rootDir, it) } - assert(handler.canMove(files.toTypedArray(), null)) + assert(handler.canMoveCompat(files.toTypedArray(), null, null)) } fun testMultipleTopLevelDeclarationsInDifferentDirs() = doTest { rootDir, handler -> val declarations = listOf("test1/test.kt", "test2/test2.kt").flatMap { getElementsAtCarets(rootDir, it) } .map { it.getNonStrictParentOfType()!! } - assert(!handler.canMove(declarations.toTypedArray(), null)) + assert(!handler.canMoveCompat(declarations.toTypedArray(), null, null)) val files = listOf("test1/test.kt", "test2/test2.kt").map { getPsiFile(rootDir, it) } - assert(!handler.canMove(files.toTypedArray(), null)) + assert(!handler.canMoveCompat(files.toTypedArray(), null, null)) } fun testFileAndTopLevelDeclarations() = doTest { rootDir, handler -> @@ -142,20 +142,20 @@ class MoveKotlinDeclarationsHandlerTest : KotlinMultiFileTestCase() { rootDir, "test2.kt" ) - assert(!handler.canMove(elements.toTypedArray(), null)) + assert(!handler.canMoveCompat(elements.toTypedArray(), null, null)) } fun testCommonTargets() = doTest { rootDir, handler -> val elementsToMove = arrayOf(getElementAtCaret(rootDir, "test.kt").getNonStrictParentOfType()!!) val targetPackage = JavaPsiFacade.getInstance(project).findPackage("pack")!! - assert(handler.canMove(elementsToMove, targetPackage)) + assert(handler.canMoveCompat(elementsToMove, targetPackage, null)) val targetDirectory = getPsiDirectory(rootDir, "pack") - assert(handler.canMove(elementsToMove, targetDirectory)) + assert(handler.canMoveCompat(elementsToMove, targetDirectory, null)) val targetFile = getPsiFile(rootDir, "pack/test2.kt") - assert(handler.canMove(elementsToMove, targetFile)) + assert(handler.canMoveCompat(elementsToMove, targetFile, null)) } fun testTopLevelClassToClass() = doTest { rootDir, handler -> @@ -164,14 +164,14 @@ class MoveKotlinDeclarationsHandlerTest : KotlinMultiFileTestCase() { val topLevelTarget = targetFile.declarations.firstIsInstance() assert(topLevelTarget.name == "B") - assert(!handler.canMove(elementsToMove, topLevelTarget)) + assert(!handler.canMoveCompat(elementsToMove, topLevelTarget, null)) val annotationTarget = targetFile.declarations.first { it.name == "Ann" } as KtClass - assert(!handler.canMove(elementsToMove, annotationTarget)) + assert(!handler.canMoveCompat(elementsToMove, annotationTarget, null)) val nestedTarget = topLevelTarget.declarations.firstIsInstance() assert(nestedTarget.name == "C") - assert(!handler.canMove(elementsToMove, nestedTarget)) + assert(!handler.canMoveCompat(elementsToMove, nestedTarget, null)) } fun testNestedClassToClass() = doTest { rootDir, handler -> @@ -180,33 +180,33 @@ class MoveKotlinDeclarationsHandlerTest : KotlinMultiFileTestCase() { val topLevelTarget = targetFile.declarations.firstIsInstance() assert(topLevelTarget.name == "B") - assert(handler.canMove(elementsToMove, topLevelTarget)) + assert(handler.canMoveCompat(elementsToMove, topLevelTarget, null)) val annotationTarget = targetFile.declarations.first { it.name == "Ann" } as KtClass - assert(!handler.canMove(elementsToMove, annotationTarget)) + assert(!handler.canMoveCompat(elementsToMove, annotationTarget, null)) val nestedTarget = topLevelTarget.declarations.firstIsInstance() assert(nestedTarget.name == "C") - assert(handler.canMove(elementsToMove, nestedTarget)) + assert(handler.canMoveCompat(elementsToMove, nestedTarget, null)) } fun testTypeAlias() = doTest { rootDir, handler -> val typeAlias = getElementAtCaret(rootDir, "test.kt").getNonStrictParentOfType()!! - assert(handler.canMove(arrayOf(typeAlias), null)) + assert(handler.canMoveCompat(arrayOf(typeAlias), null, null)) } fun testTopLevelClassInScript() = doTest { rootDir, handler -> val klass = getElementAtCaret(rootDir, "test.kts").getNonStrictParentOfType()!! - assert(handler.canMove(arrayOf(klass), null)) + assert(handler.canMoveCompat(arrayOf(klass), null, null)) } fun testTopLevelFunInScript() = doTest { rootDir, handler -> val function = getElementAtCaret(rootDir, "test.kts").getNonStrictParentOfType()!! - assert(handler.canMove(arrayOf(function), null)) + assert(handler.canMoveCompat(arrayOf(function), null, null)) } fun testTopLevelValInScript() = doTest { rootDir, handler -> val property = getElementAtCaret(rootDir, "test.kts").getNonStrictParentOfType()!! - assert(handler.canMove(arrayOf(property), null)) + assert(handler.canMoveCompat(arrayOf(property), null, null)) } } \ No newline at end of file