Change Signature: Skip secondary constructor calls when looking for primary constructor usages
#KT-7445 Fixed
This commit is contained in:
+2
@@ -114,6 +114,8 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
|
||||
for (PsiReference reference : ReferencesSearch.search(functionPsi, functionPsi.getUseScope())) {
|
||||
PsiElement element = reference.getElement();
|
||||
|
||||
if (functionPsi instanceof JetClass && reference.resolve() != functionPsi) continue;
|
||||
|
||||
if (element instanceof JetReferenceExpression) {
|
||||
PsiElement parent = element.getParent();
|
||||
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class Test {
|
||||
void test() {
|
||||
new C("");
|
||||
new C("2", "1");
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class C(p2: String, p1: String) {
|
||||
public constructor(p: String) : this(p, p) {}
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
C("")
|
||||
C("2", "1")
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class Test {
|
||||
void test() {
|
||||
new C("");
|
||||
new C("1", "2");
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class <caret>C(p1: String, p2: String) {
|
||||
public constructor(p: String) : this(p, p) {}
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
C("")
|
||||
C("1", "2")
|
||||
}
|
||||
+8
-1
@@ -49,7 +49,6 @@ import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.kotlin.idea.refactoring.changeSignature.ChangeSignaturePackage.getChangeSignatureDialog;
|
||||
import static org.jetbrains.kotlin.psi.PsiPackage.JetPsiFactory;
|
||||
|
||||
public class JetChangeSignatureTest extends KotlinCodeInsightTestCase {
|
||||
public void testBadSelection() throws Exception {
|
||||
@@ -841,6 +840,14 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase {
|
||||
doTest(changeInfo);
|
||||
}
|
||||
|
||||
public void testDoNotApplyPrimarySignatureToSecondaryCalls() throws Exception {
|
||||
JetChangeInfo changeInfo = getChangeInfo();
|
||||
JetParameterInfo[] newParameters = changeInfo.getNewParameters();
|
||||
changeInfo.setNewParameter(0, newParameters[1]);
|
||||
changeInfo.setNewParameter(1, newParameters[0]);
|
||||
doTest(changeInfo);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
|
||||
Reference in New Issue
Block a user