Change Signature: Initialize JetFunctionCallUsage delegate early to ensure consistent analysis results

This commit is contained in:
Alexey Sedunov
2015-04-24 17:33:35 +03:00
parent 720e696f6b
commit bd6031fea1
3 changed files with 20 additions and 17 deletions
@@ -119,7 +119,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
private static void findOneMethodUsages( private static void findOneMethodUsages(
@NotNull JetFunctionDefinitionUsage<?> functionUsageInfo, @NotNull JetFunctionDefinitionUsage<?> functionUsageInfo,
JetChangeInfo changeInfo, final JetChangeInfo changeInfo,
final Set<UsageInfo> result final Set<UsageInfo> result
) { ) {
boolean isInherited = functionUsageInfo.isInherited(); boolean isInherited = functionUsageInfo.isInherited();
@@ -194,15 +194,17 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
} }
} }
UsagesSearchPackage.processDelegationCallConstructorUsages(functionPsi, functionPsi.getUseScope(), UsagesSearchPackage.processDelegationCallConstructorUsages(
new Function1<JetConstructorDelegationCall, Unit>() { functionPsi,
@Override functionPsi.getUseScope(),
public Unit invoke(JetConstructorDelegationCall element) { new Function1<JetConstructorDelegationCall, Unit>() {
result.add(new JetConstructorDelegationCallUsage(element)); @Override
return null; public Unit invoke(JetConstructorDelegationCall element) {
} result.add(new JetConstructorDelegationCallUsage(element, changeInfo));
}); return null;
}
}
);
} }
private static void processInternalReferences( private static void processInternalReferences(
@@ -50,7 +50,7 @@ public class JavaConstructorDeferredUsageInDelegationCall(
): JavaMethodDeferredKotlinUsage<JetConstructorDelegationCall>(delegationCall) { ): JavaMethodDeferredKotlinUsage<JetConstructorDelegationCall>(delegationCall) {
override fun resolve(javaMethodChangeInfo: JetChangeInfo): JavaMethodKotlinUsageWithDelegate<JetConstructorDelegationCall> { override fun resolve(javaMethodChangeInfo: JetChangeInfo): JavaMethodKotlinUsageWithDelegate<JetConstructorDelegationCall> {
return object : JavaMethodKotlinUsageWithDelegate<JetConstructorDelegationCall>(delegationCall, javaMethodChangeInfo) { return object : JavaMethodKotlinUsageWithDelegate<JetConstructorDelegationCall>(delegationCall, javaMethodChangeInfo) {
override val delegateUsage = JetConstructorDelegationCallUsage(delegationCall) override val delegateUsage = JetConstructorDelegationCallUsage(delegationCall, javaMethodChangeInfo)
} }
} }
} }
@@ -16,15 +16,17 @@
package org.jetbrains.kotlin.idea.refactoring.changeSignature.usages package org.jetbrains.kotlin.idea.refactoring.changeSignature.usages
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetChangeInfo import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetChangeInfo
import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.psi.JetConstructorDelegationCall import org.jetbrains.kotlin.psi.JetConstructorDelegationCall
import org.jetbrains.kotlin.psi.JetPsiFactory import org.jetbrains.kotlin.psi.JetPsiFactory
import org.jetbrains.kotlin.psi.JetSecondaryConstructor import org.jetbrains.kotlin.psi.JetSecondaryConstructor
public class JetConstructorDelegationCallUsage(call: JetConstructorDelegationCall) : JetUsageInfo<JetConstructorDelegationCall>(call) { public class JetConstructorDelegationCallUsage(
call: JetConstructorDelegationCall,
changeInfo: JetChangeInfo
) : JetUsageInfo<JetConstructorDelegationCall>(call) {
val delegate = JetFunctionCallUsage(call, changeInfo.methodDescriptor.originalPrimaryFunction)
override fun processUsage(changeInfo: JetChangeInfo, element: JetConstructorDelegationCall): Boolean { override fun processUsage(changeInfo: JetChangeInfo, element: JetConstructorDelegationCall): Boolean {
val isThisCall = element.isCallToThis() val isThisCall = element.isCallToThis()
@@ -34,8 +36,7 @@ public class JetConstructorDelegationCallUsage(call: JetConstructorDelegationCal
elementToWorkWith = constructor.replaceImplicitDelegationCallWithExplicit(isThisCall) elementToWorkWith = constructor.replaceImplicitDelegationCallWithExplicit(isThisCall)
} }
val result = JetFunctionCallUsage( val result = delegate.processUsage(changeInfo, elementToWorkWith)
elementToWorkWith, changeInfo.methodDescriptor.originalPrimaryFunction).processUsage(changeInfo, elementToWorkWith)
if (changeInfo.getNewParametersCount() == 0 && !isThisCall && !elementToWorkWith.isImplicit()) { if (changeInfo.getNewParametersCount() == 0 && !isThisCall && !elementToWorkWith.isImplicit()) {
(elementToWorkWith.getParent() as? JetSecondaryConstructor)?.getColon()?.delete() (elementToWorkWith.getParent() as? JetSecondaryConstructor)?.getColon()?.delete()