Change Signature: Fix parameter name for kt-function overriding Java's
#KT-24763 Fixed
This commit is contained in:
+7
-3
@@ -442,12 +442,15 @@ class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor {
|
|||||||
|
|
||||||
private fun findKotlinOverrides(changeInfo: ChangeInfo, result: MutableSet<UsageInfo>) {
|
private fun findKotlinOverrides(changeInfo: ChangeInfo, result: MutableSet<UsageInfo>) {
|
||||||
val method = changeInfo.method as? PsiMethod ?: return
|
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)) {
|
for (overridingMethod in OverridingMethodsSearch.search(method)) {
|
||||||
val unwrappedElement = overridingMethod.namedUnwrappedElement as? KtNamedFunction ?: continue
|
val unwrappedElement = overridingMethod.namedUnwrappedElement as? KtNamedFunction ?: continue
|
||||||
val functionDescriptor = unwrappedElement.resolveToDescriptorIfAny() ?: continue
|
val functionDescriptor = unwrappedElement.resolveToDescriptorIfAny() ?: continue
|
||||||
result.add(DeferredJavaMethodOverrideOrSAMUsage(unwrappedElement, functionDescriptor, null))
|
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,
|
changeInfo: ChangeInfo,
|
||||||
result: MutableSet<UsageInfo>,
|
result: MutableSet<UsageInfo>,
|
||||||
function: KtNamedFunction,
|
function: KtNamedFunction,
|
||||||
functionDescriptor: FunctionDescriptor) {
|
functionDescriptor: FunctionDescriptor,
|
||||||
val functionInfoForParameters = KotlinCallableDefinitionUsage<PsiElement>(function, functionDescriptor, null, null)
|
baseFunctionInfo: KotlinCallableDefinitionUsage<PsiElement>) {
|
||||||
|
val functionInfoForParameters = KotlinCallableDefinitionUsage<PsiElement>(function, functionDescriptor, baseFunctionInfo, null)
|
||||||
val oldParameters = function.valueParameters
|
val oldParameters = function.valueParameters
|
||||||
val parameters = changeInfo.newParameters
|
val parameters = changeInfo.newParameters
|
||||||
for ((paramIndex, parameterInfo) in parameters.withIndex()) {
|
for ((paramIndex, parameterInfo) in parameters.withIndex()) {
|
||||||
|
|||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
class K : J() {
|
||||||
|
override fun foo(name: String, n: Int) = name.length
|
||||||
|
}
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
abstract class J {
|
||||||
|
abstract int foo(String s, int n);
|
||||||
|
}
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
class K : J() {
|
||||||
|
override fun foo(name: String) = name.length
|
||||||
|
}
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
abstract class J {
|
||||||
|
abstract int <caret>foo(String s);
|
||||||
|
}
|
||||||
+4
@@ -1008,4 +1008,8 @@ class KotlinChangeSignatureTest : KotlinLightCodeInsightFixtureTestCase() {
|
|||||||
fun testGetConventionRenameToFoo() = doTest { newName = "foo" }
|
fun testGetConventionRenameToFoo() = doTest { newName = "foo" }
|
||||||
|
|
||||||
fun testGetConventionRenameToInvoke() = doTest { newName = "invoke" }
|
fun testGetConventionRenameToInvoke() = doTest { newName = "invoke" }
|
||||||
|
|
||||||
|
fun testKotlinOverridingJavaWithDifferentParamName() = doJavaTest {
|
||||||
|
newParameters.add(ParameterInfoImpl(-1, "n", PsiType.INT))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user