Rename: Fix exception on property rename preview
(cherry picked from commit 7b54ad0)
This commit is contained in:
@@ -132,6 +132,7 @@ These artifacts include extensions for the types available in the latter JDKs, s
|
|||||||
- [`KT-12294`](https://youtrack.jetbrains.com/issue/KT-12294) Introduce Property: Fix extraction of expressions referring to primary constructor parameters
|
- [`KT-12294`](https://youtrack.jetbrains.com/issue/KT-12294) Introduce Property: Fix extraction of expressions referring to primary constructor parameters
|
||||||
- [`KT-12413`](https://youtrack.jetbrains.com/issue/KT-12413) Change Signature: Fix bogus warning about unresolved type parameters/invalid functional type replacement
|
- [`KT-12413`](https://youtrack.jetbrains.com/issue/KT-12413) Change Signature: Fix bogus warning about unresolved type parameters/invalid functional type replacement
|
||||||
- [`KT-12084`](https://youtrack.jetbrains.com/issue/KT-12084) Introduce Property: Do not skip outer classes if extractable expression is contained in object literal
|
- [`KT-12084`](https://youtrack.jetbrains.com/issue/KT-12084) Introduce Property: Do not skip outer classes if extractable expression is contained in object literal
|
||||||
|
- [`KT-13082`](https://youtrack.jetbrains.com/issue/KT-13082) Rename: Fix exception on property rename preview
|
||||||
|
|
||||||
###### New features
|
###### New features
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||||
import org.jetbrains.kotlin.idea.refactoring.rename.RenameJavaSyntheticPropertyHandler
|
import org.jetbrains.kotlin.idea.refactoring.rename.RenameJavaSyntheticPropertyHandler
|
||||||
|
import org.jetbrains.kotlin.idea.refactoring.rename.RenameKotlinPropertyProcessor
|
||||||
import org.jetbrains.kotlin.idea.search.usagesSearch.descriptor
|
import org.jetbrains.kotlin.idea.search.usagesSearch.descriptor
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
@@ -52,6 +53,7 @@ class KotlinElementDescriptionProvider : ElementDescriptionProvider {
|
|||||||
is KtDestructuringDeclarationEntry -> "variable"
|
is KtDestructuringDeclarationEntry -> "variable"
|
||||||
is RenameJavaSyntheticPropertyHandler.SyntheticPropertyWrapper -> "property"
|
is RenameJavaSyntheticPropertyHandler.SyntheticPropertyWrapper -> "property"
|
||||||
is KtLightClassForFacade -> "facade class"
|
is KtLightClassForFacade -> "facade class"
|
||||||
|
is RenameKotlinPropertyProcessor.PropertyMethodWrapper -> "property accessor"
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-4
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.refactoring.rename
|
package org.jetbrains.kotlin.idea.refactoring.rename
|
||||||
|
|
||||||
|
import com.intellij.navigation.NavigationItem
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import com.intellij.openapi.ui.Messages
|
import com.intellij.openapi.ui.Messages
|
||||||
@@ -249,6 +250,12 @@ class RenameKotlinPropertyProcessor : RenameKotlinPsiProcessor() {
|
|||||||
return declarationToRename
|
return declarationToRename
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class PropertyMethodWrapper(val propertyMethod: PsiMethod) : PsiNamedElement by propertyMethod, NavigationItem by propertyMethod {
|
||||||
|
override fun getName() = propertyMethod.name
|
||||||
|
override fun setName(name: String) = this
|
||||||
|
override fun copy() = this
|
||||||
|
}
|
||||||
|
|
||||||
override fun prepareRenaming(element: PsiElement, newName: String?, allRenames: MutableMap<PsiElement, String>, scope: SearchScope) {
|
override fun prepareRenaming(element: PsiElement, newName: String?, allRenames: MutableMap<PsiElement, String>, scope: SearchScope) {
|
||||||
super.prepareRenaming(element, newName, allRenames, scope)
|
super.prepareRenaming(element, newName, allRenames, scope)
|
||||||
|
|
||||||
@@ -281,10 +288,7 @@ class RenameKotlinPropertyProcessor : RenameKotlinPsiProcessor() {
|
|||||||
|
|
||||||
for (propertyMethod in propertyMethods) {
|
for (propertyMethod in propertyMethods) {
|
||||||
if (element is KtDeclaration && newPropertyName != null) {
|
if (element is KtDeclaration && newPropertyName != null) {
|
||||||
val wrapper = object : PsiNamedElement by propertyMethod {
|
val wrapper = PropertyMethodWrapper(propertyMethod)
|
||||||
override fun setName(name: String) = this
|
|
||||||
override fun copy() = this
|
|
||||||
}
|
|
||||||
when {
|
when {
|
||||||
JvmAbi.isGetterName(propertyMethod.name) && getterJvmName == null ->
|
JvmAbi.isGetterName(propertyMethod.name) && getterJvmName == null ->
|
||||||
allRenames[wrapper] = JvmAbi.getterName(newPropertyName)
|
allRenames[wrapper] = JvmAbi.getterName(newPropertyName)
|
||||||
|
|||||||
Reference in New Issue
Block a user