move members: update static imports when methods are overridden (IDEA-93741)

This commit is contained in:
anna
2012-10-26 16:32:06 +02:00
parent 4c1ebfc416
commit 5516da73c7
8 changed files with 44 additions and 1 deletions
@@ -238,7 +238,12 @@ public class RefactoringUtil {
if (importList != null) {
final PsiImportStaticStatement[] importStaticStatements = importList.getImportStaticStatements();
for(PsiImportStaticStatement stmt: importStaticStatements) {
if (!stmt.isOnDemand() && stmt.resolveTargetClass() == member.getContainingClass() && Comparing.strEqual(stmt.getReferenceName(), member.getName())) {
final PsiClass containingClass = member.getContainingClass();
final String referenceName = stmt.getReferenceName();
if (!stmt.isOnDemand() && stmt.resolveTargetClass() == containingClass && Comparing.strEqual(referenceName, member.getName())) {
if (member instanceof PsiMethod) {
return containingClass.findMethodsByName(referenceName, false).length == 1;
}
return true;
}
}
@@ -0,0 +1,5 @@
package bar;
public class A {
public static void foo() {}
}
@@ -0,0 +1,5 @@
package bar;
public class B {
public static void foo(String s) {}
}
@@ -0,0 +1,7 @@
import bar.A;
class Usage {
void bar() {
A.foo();
}
}
@@ -0,0 +1,4 @@
package bar;
public class A {
}
@@ -0,0 +1,6 @@
package bar;
public class B {
public static void foo() {}
public static void foo(String s) {}
}
@@ -0,0 +1,7 @@
import static bar.B.foo;
class Usage {
void bar() {
foo();
}
}
@@ -105,6 +105,10 @@ public class MoveMembersTest extends MultiFileTestCase {
doTest("B", "A", 0);
}
public void testStaticImportAndOverridenMethods() throws Exception {
doTest("bar.B", "bar.A", 0);
}
public void testWritableField() throws Exception {
try {
doTest("B", "A", 0);