Change Signature: Fix exception on applying to impl declaration
This commit is contained in:
+5
-6
@@ -30,11 +30,12 @@ import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
|
|||||||
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
||||||
import org.jetbrains.kotlin.idea.highlighter.markers.headerImplementations
|
import org.jetbrains.kotlin.idea.highlighter.markers.headerImplementations
|
||||||
import org.jetbrains.kotlin.idea.highlighter.markers.isHeaderOrHeaderClassMember
|
import org.jetbrains.kotlin.idea.highlighter.markers.isHeaderOrHeaderClassMember
|
||||||
import org.jetbrains.kotlin.idea.highlighter.markers.liftToHeader
|
|
||||||
import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinCallableDefinitionUsage
|
import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinCallableDefinitionUsage
|
||||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.KtClass
|
||||||
|
import org.jetbrains.kotlin.psi.KtFunction
|
||||||
|
import org.jetbrains.kotlin.psi.KtNamedDeclaration
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@@ -86,9 +87,7 @@ class KotlinChangeSignatureData(
|
|||||||
|
|
||||||
override val primaryCallables: Collection<KotlinCallableDefinitionUsage<PsiElement>> by lazy {
|
override val primaryCallables: Collection<KotlinCallableDefinitionUsage<PsiElement>> by lazy {
|
||||||
descriptorsForSignatureChange.map {
|
descriptorsForSignatureChange.map {
|
||||||
val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(baseDeclaration.project, it)?.let {
|
val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(baseDeclaration.project, it)
|
||||||
(it as? KtDeclaration)?.liftToHeader() ?: it
|
|
||||||
}
|
|
||||||
assert(declaration != null) { "No declaration found for " + baseDescriptor }
|
assert(declaration != null) { "No declaration found for " + baseDescriptor }
|
||||||
KotlinCallableDefinitionUsage(declaration!!, it, null, null)
|
KotlinCallableDefinitionUsage(declaration!!, it, null, null)
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.SYNTHESIZE
|
|||||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||||
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
|
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
|
||||||
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
||||||
|
import org.jetbrains.kotlin.idea.highlighter.markers.headerDescriptor
|
||||||
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle
|
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle
|
||||||
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor
|
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
@@ -164,6 +165,9 @@ class KotlinChangeSignatureHandler : ChangeSignatureHandler {
|
|||||||
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, element)) return null
|
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, element)) return null
|
||||||
|
|
||||||
var descriptor = getDescriptor(bindingContext, element)
|
var descriptor = getDescriptor(bindingContext, element)
|
||||||
|
if (descriptor is MemberDescriptor && descriptor.isImpl) {
|
||||||
|
descriptor = descriptor.headerDescriptor() ?: descriptor
|
||||||
|
}
|
||||||
|
|
||||||
return when (descriptor) {
|
return when (descriptor) {
|
||||||
is FunctionDescriptor -> {
|
is FunctionDescriptor -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user