Change Signature: Fix parameter name for kt-function overriding Java's

#KT-24763 Fixed
This commit is contained in:
Alexey Sedunov
2018-06-04 17:41:44 +03:00
parent 8978c4b9e8
commit 8a838ab5bb
6 changed files with 23 additions and 3 deletions
@@ -442,12 +442,15 @@ class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor {
private fun findKotlinOverrides(changeInfo: ChangeInfo, result: MutableSet<UsageInfo>) {
val method = changeInfo.method as? PsiMethod ?: return
val methodDescriptor = method.getJavaMethodDescriptor() ?: return
val baseFunctionInfo = KotlinCallableDefinitionUsage<PsiElement>(method, methodDescriptor, null, null)
for (overridingMethod in OverridingMethodsSearch.search(method)) {
val unwrappedElement = overridingMethod.namedUnwrappedElement as? KtNamedFunction ?: continue
val functionDescriptor = unwrappedElement.resolveToDescriptorIfAny() ?: continue
result.add(DeferredJavaMethodOverrideOrSAMUsage(unwrappedElement, functionDescriptor, null))
findDeferredUsagesOfParameters(changeInfo, result, unwrappedElement, functionDescriptor)
findDeferredUsagesOfParameters(changeInfo, result, unwrappedElement, functionDescriptor, baseFunctionInfo)
}
}
@@ -474,8 +477,9 @@ class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor {
changeInfo: ChangeInfo,
result: MutableSet<UsageInfo>,
function: KtNamedFunction,
functionDescriptor: FunctionDescriptor) {
val functionInfoForParameters = KotlinCallableDefinitionUsage<PsiElement>(function, functionDescriptor, null, null)
functionDescriptor: FunctionDescriptor,
baseFunctionInfo: KotlinCallableDefinitionUsage<PsiElement>) {
val functionInfoForParameters = KotlinCallableDefinitionUsage<PsiElement>(function, functionDescriptor, baseFunctionInfo, null)
val oldParameters = function.valueParameters
val parameters = changeInfo.newParameters
for ((paramIndex, parameterInfo) in parameters.withIndex()) {
@@ -0,0 +1,3 @@
class K : J() {
override fun foo(name: String, n: Int) = name.length
}
@@ -0,0 +1,3 @@
abstract class J {
abstract int foo(String s, int n);
}
@@ -0,0 +1,3 @@
class K : J() {
override fun foo(name: String) = name.length
}
@@ -0,0 +1,3 @@
abstract class J {
abstract int <caret>foo(String s);
}
@@ -1008,4 +1008,8 @@ class KotlinChangeSignatureTest : KotlinLightCodeInsightFixtureTestCase() {
fun testGetConventionRenameToFoo() = doTest { newName = "foo" }
fun testGetConventionRenameToInvoke() = doTest { newName = "invoke" }
fun testKotlinOverridingJavaWithDifferentParamName() = doJavaTest {
newParameters.add(ParameterInfoImpl(-1, "n", PsiType.INT))
}
}