pull up: update references in hierarchy for static methods in interfaces

IDEA-186590
This commit is contained in:
Anna.Kozlova
2018-02-15 19:47:07 +01:00
parent 7474c9d0cc
commit ab90341de0
6 changed files with 42 additions and 0 deletions
@@ -328,6 +328,9 @@ public class JavaPullUpHelper implements PullUpHelper<MemberInfo> {
if (qualifierExpression instanceof PsiReferenceExpression && ((PsiReferenceExpression)qualifierExpression).resolve() == mySourceClass) {
((PsiReferenceExpression)qualifierExpression).bindToElement(myTargetSuperClass);
}
else if (qualifierExpression == null && myTargetSuperClass.isInterface()) {
((PsiReferenceExpression)element).setQualifierExpression(JavaPsiFacade.getElementFactory(myProject).createReferenceExpression(myTargetSuperClass));
}
}
}
@@ -1,5 +1,9 @@
class Foo {}
class FooImpl extends Foo {
{
foo();
}
public static void foo(){}
<caret>
}
@@ -0,0 +1,14 @@
interface Foo {}
class FooImpl implements Foo {
{
foo();
}
public static void foo(){}
<caret>
}
class U {
public static void main(String[] args) {
FooImpl.foo();
}
}
@@ -0,0 +1,14 @@
interface Foo {
static void foo(){}
}
class FooImpl implements Foo {
{
Foo.foo();
}
}
class U {
public static void main(String[] args) {
Foo.foo();
}
}
@@ -2,6 +2,9 @@ class Foo {
public static void foo(){}
}
class FooImpl extends Foo {
{
foo();
}
}
class U {
@@ -141,6 +141,10 @@ public class PullUpTest extends LightRefactoringTestCase {
doTest(false, new RefactoringTestUtil.MemberDescriptor("foo", PsiMethod.class));
}
public void testUpdateStaticRefsForInterface() {
doTest(false, new RefactoringTestUtil.MemberDescriptor("foo", PsiMethod.class));
}
public void testRemoveOverrideFromPulledMethod() {
doTest(false, new RefactoringTestUtil.MemberDescriptor("foo", PsiMethod.class));
}