[kotlin] Introduce KotlinMoveRefactoringSupport

^KTIJ-23273 A compiler version agnostic interface to be used in common code for the move refactoring.

GitOrigin-RevId: 57c8b6291e6da618de552d38ab87ee053dfed947
This commit is contained in:
Bart van Helvert
2023-04-28 13:11:37 +00:00
committed by intellij-monorepo-bot
parent 63e34c4bf3
commit 179f71a4f4
3 changed files with 33 additions and 0 deletions
@@ -0,0 +1,14 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.idea.refactoring.move
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiReference
import com.intellij.psi.search.SearchScope
import org.jetbrains.kotlin.idea.base.searching.usages.KotlinFindUsagesHandlerFactory
internal class K1MoveRefactoringSupport : KotlinMoveRefactoringSupport {
override fun findReferencesToHighlight(target: PsiElement, searchScope: SearchScope): Collection<PsiReference> {
return KotlinFindUsagesHandlerFactory(target.project).createFindUsagesHandler(target, false)
.findReferencesToHighlight(target, searchScope)
}
}
@@ -35,6 +35,9 @@
<refactoring.helper implementation="org.jetbrains.kotlin.idea.codeInsight.KotlinRefactoringHelperForDelayedRequests"/>
<refactoring.helper implementation="org.jetbrains.kotlin.idea.codeInsight.KotlinOptimizeImportsRefactoringHelper"/>
<applicationService serviceImplementation="org.jetbrains.kotlin.idea.refactoring.move.K1MoveRefactoringSupport"
serviceInterface="org.jetbrains.kotlin.idea.refactoring.move.KotlinMoveRefactoringSupport"/>
<refactoring.moveHandler
id="kotlin.moveMethod"
order="first"
@@ -0,0 +1,16 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.idea.refactoring.move
import com.intellij.openapi.components.service
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiReference
import com.intellij.psi.search.SearchScope
interface KotlinMoveRefactoringSupport {
companion object {
@JvmStatic
fun getInstance(): KotlinMoveRefactoringSupport = service()
}
fun findReferencesToHighlight(target: PsiElement, searchScope: SearchScope): Collection<PsiReference>
}