Preparation for bunching RenameKotlin*Processor.kt
Relates to #KT-37801
This commit is contained in:
+1
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
|||||||
import org.jetbrains.kotlin.utils.SmartList
|
import org.jetbrains.kotlin.utils.SmartList
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
// BUNCH 191
|
||||||
class RenameKotlinClassifierProcessor : RenameKotlinPsiProcessor() {
|
class RenameKotlinClassifierProcessor : RenameKotlinPsiProcessor() {
|
||||||
override fun canProcessElement(element: PsiElement): Boolean {
|
override fun canProcessElement(element: PsiElement): Boolean {
|
||||||
return element is KtClassOrObject || element is KtLightClass || element is KtConstructor<*> || element is KtTypeAlias
|
return element is KtClassOrObject || element is KtLightClass || element is KtConstructor<*> || element is KtTypeAlias
|
||||||
+1
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
// BUNCH 191
|
||||||
class RenameKotlinFunctionProcessor : RenameKotlinPsiProcessor() {
|
class RenameKotlinFunctionProcessor : RenameKotlinPsiProcessor() {
|
||||||
private val javaMethodProcessorInstance = RenameJavaMethodProcessor()
|
private val javaMethodProcessorInstance = RenameJavaMethodProcessor()
|
||||||
|
|
||||||
-47
@@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.rename
|
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
|
||||||
import com.intellij.refactoring.listeners.RefactoringElementListener
|
|
||||||
import com.intellij.usageView.UsageInfo
|
|
||||||
import org.jetbrains.kotlin.asJava.namedUnwrappedElement
|
|
||||||
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringSettings
|
|
||||||
import org.jetbrains.kotlin.psi.KtFunction
|
|
||||||
import org.jetbrains.kotlin.psi.KtNamedDeclaration
|
|
||||||
import org.jetbrains.kotlin.psi.KtParameter
|
|
||||||
import org.jetbrains.kotlin.utils.SmartList
|
|
||||||
|
|
||||||
class RenameKotlinParameterProcessor : RenameKotlinPsiProcessor() {
|
|
||||||
override fun canProcessElement(element: PsiElement) = element is KtParameter && element.ownerFunction is KtFunction
|
|
||||||
|
|
||||||
override fun isToSearchInComments(psiElement: PsiElement) = KotlinRefactoringSettings.instance.RENAME_SEARCH_IN_COMMENTS_FOR_VARIABLE
|
|
||||||
|
|
||||||
override fun setToSearchInComments(element: PsiElement, enabled: Boolean) {
|
|
||||||
KotlinRefactoringSettings.instance.RENAME_SEARCH_IN_COMMENTS_FOR_VARIABLE = enabled
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun findCollisions(
|
|
||||||
element: PsiElement,
|
|
||||||
newName: String,
|
|
||||||
allRenames: MutableMap<out PsiElement, String>,
|
|
||||||
result: MutableList<UsageInfo>
|
|
||||||
) {
|
|
||||||
val declaration = element.namedUnwrappedElement as? KtNamedDeclaration ?: return
|
|
||||||
|
|
||||||
val collisions = SmartList<UsageInfo>()
|
|
||||||
checkRedeclarations(declaration, newName, collisions)
|
|
||||||
checkOriginalUsagesRetargeting(declaration, newName, result, collisions)
|
|
||||||
checkNewNameUsagesRetargeting(declaration, newName, collisions)
|
|
||||||
result += collisions
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun renameElement(element: PsiElement, newName: String, usages: Array<UsageInfo>, listener: RefactoringElementListener?) {
|
|
||||||
super.renameElement(element, newName, usages, listener)
|
|
||||||
|
|
||||||
usages.forEach { (it as? KtResolvableCollisionUsageInfo)?.apply() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
@@ -63,6 +63,7 @@ import org.jetbrains.kotlin.util.findCallableMemberBySignature
|
|||||||
import org.jetbrains.kotlin.utils.DFS
|
import org.jetbrains.kotlin.utils.DFS
|
||||||
import org.jetbrains.kotlin.utils.SmartList
|
import org.jetbrains.kotlin.utils.SmartList
|
||||||
|
|
||||||
|
// BUNCH 191
|
||||||
class RenameKotlinPropertyProcessor : RenameKotlinPsiProcessor() {
|
class RenameKotlinPropertyProcessor : RenameKotlinPsiProcessor() {
|
||||||
override fun canProcessElement(element: PsiElement): Boolean {
|
override fun canProcessElement(element: PsiElement): Boolean {
|
||||||
val namedUnwrappedElement = element.namedUnwrappedElement
|
val namedUnwrappedElement = element.namedUnwrappedElement
|
||||||
+1
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.resolve.ImportPath
|
|||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
import kotlin.collections.*
|
import kotlin.collections.*
|
||||||
|
|
||||||
|
// BUNCH 191
|
||||||
abstract class RenameKotlinPsiProcessor : RenamePsiElementProcessor() {
|
abstract class RenameKotlinPsiProcessor : RenamePsiElementProcessor() {
|
||||||
class MangledJavaRefUsageInfo(
|
class MangledJavaRefUsageInfo(
|
||||||
val manglingSuffix: String,
|
val manglingSuffix: String,
|
||||||
Reference in New Issue
Block a user