mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extract method duplicates: distinguish method overloads (IDEA-97777)
This commit is contained in:
@@ -394,6 +394,12 @@ public class DuplicatesFinder {
|
||||
match.registerReturnValue(new ContinueReturnValue());
|
||||
} else if (pattern instanceof PsiBreakStatement) {
|
||||
match.registerReturnValue(new BreakReturnValue());
|
||||
}else if (pattern instanceof PsiMethodCallExpression) {
|
||||
final PsiMethod patternMethod = ((PsiMethodCallExpression)pattern).resolveMethod();
|
||||
final PsiMethod candidateMethod = ((PsiMethodCallExpression)candidate).resolveMethod();
|
||||
if (patternMethod != null && candidateMethod != null) {
|
||||
if (!MethodSignatureUtil.areSignaturesEqual(patternMethod, candidateMethod)) return false;
|
||||
}
|
||||
} else if (pattern instanceof PsiReferenceExpression) {
|
||||
final PsiReferenceExpression patternRefExpr = (PsiReferenceExpression)pattern;
|
||||
final PsiReferenceExpression candidateRefExpr = (PsiReferenceExpression)candidate;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class Test {
|
||||
public void myTest(List list, String s1, String s2) {
|
||||
}
|
||||
|
||||
public void myTest(Collection list, String s1, String s2) {
|
||||
}
|
||||
|
||||
public void usage() {
|
||||
List list = new ArrayList();
|
||||
String aa = "AA";
|
||||
String bb = "bb";
|
||||
myTest(list, aa, bb);
|
||||
Collection col = new ArrayList();
|
||||
<selection>myTest(col, aa, bb);</selection>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class Test {
|
||||
public void myTest(List list, String s1, String s2) {
|
||||
}
|
||||
|
||||
public void myTest(Collection list, String s1, String s2) {
|
||||
}
|
||||
|
||||
public void usage() {
|
||||
List list = new ArrayList();
|
||||
String aa = "AA";
|
||||
String bb = "bb";
|
||||
myTest(list, aa, bb);
|
||||
Collection col = new ArrayList();
|
||||
newMethod(aa, bb, col);
|
||||
}
|
||||
|
||||
private void newMethod(String aa, String bb, Collection col) {
|
||||
myTest(col, aa, bb);
|
||||
}
|
||||
}
|
||||
@@ -583,6 +583,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
doDuplicatesTest();
|
||||
}
|
||||
|
||||
public void testOverloadedMethods() throws Exception {
|
||||
doDuplicatesTest();
|
||||
}
|
||||
|
||||
public void testTargetAnonymous() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user