Rename: Rename overridden property and all its accessors on attempt to rename overriding accessor in Java code
#KT-4791 Fixed (cherry picked from commit 29e450e)
This commit is contained in:
@@ -38,7 +38,8 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
|
||||
class KotlinElementDescriptionProvider : ElementDescriptionProvider {
|
||||
override fun getElementDescription(element: PsiElement, location: ElementDescriptionLocation): String? {
|
||||
val targetElement = element.unwrapped ?: element
|
||||
val shouldUnwrap = location !is UsageViewShortNameLocation && location !is UsageViewLongNameLocation
|
||||
val targetElement = if (shouldUnwrap) element.unwrapped ?: element else element
|
||||
|
||||
fun elementKind() = when (targetElement) {
|
||||
is KtClass -> if (targetElement.isInterface()) "interface" else "class"
|
||||
@@ -65,7 +66,7 @@ class KotlinElementDescriptionProvider : ElementDescriptionProvider {
|
||||
if (targetElement !is PsiNamedElement || targetElement.language != KotlinLanguage.INSTANCE) return null
|
||||
return when(location) {
|
||||
is UsageViewTypeLocation -> elementKind()
|
||||
is UsageViewShortNameLocation, is UsageViewLongNameLocation -> targetElement.getName()
|
||||
is UsageViewShortNameLocation, is UsageViewLongNameLocation -> targetElement.name
|
||||
is RefactoringDescriptionLocation -> {
|
||||
val kind = elementKind() ?: return null
|
||||
val descriptor = targetDescriptor() ?: return null
|
||||
|
||||
+3
-1
@@ -243,8 +243,10 @@ class RenameKotlinPropertyProcessor : RenameKotlinPsiProcessor() {
|
||||
else -> throw IllegalStateException("Can't be for element $element there because of canProcessElement()")
|
||||
}
|
||||
|
||||
val newPropertyName = if (newName != null && element is KtLightMethod) propertyNameByAccessor(newName, element) else newName
|
||||
|
||||
for (propertyMethod in propertyMethods) {
|
||||
addRenameElements(propertyMethod, (element as PsiNamedElement).name, newName, allRenames, scope)
|
||||
addRenameElements(propertyMethod, (element as PsiNamedElement).name, newPropertyName, allRenames, scope)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user