push down: order abstract/default/static (IDEA-148492)

This commit is contained in:
Anna.Kozlova
2016-05-04 20:18:45 +02:00
parent a0bd5aa11a
commit 3042cbb344
18 changed files with 125 additions and 6 deletions
@@ -218,15 +218,21 @@ public class JavaPushDownDelegate extends PushDownDelegate<MemberInfo, PsiMember
if (methodBySignature == null) {
newMember = (PsiMethod)targetClass.add(method);
if (sourceClass.isInterface()) {
final PsiMethod oldMethod = (PsiMethod)memberInfo.getMember();
if (!targetClass.isInterface()) {
PsiUtil.setModifierProperty(newMember, PsiModifier.PUBLIC, true);
if (newMember.hasModifierProperty(PsiModifier.DEFAULT)) {
PsiUtil.setModifierProperty(newMember, PsiModifier.DEFAULT, false);
if (oldMethod.hasModifierProperty(PsiModifier.ABSTRACT)) {
RefactoringUtil.makeMethodAbstract(targetClass, (PsiMethod)newMember);
}
else {
PsiUtil.setModifierProperty(newMember, PsiModifier.ABSTRACT, true);
PsiUtil.setModifierProperty(newMember, PsiModifier.DEFAULT, false);
}
}
if (memberInfo.isToAbstract() && oldMethod.hasModifierProperty(PsiModifier.DEFAULT)) {
PsiUtil.setModifierProperty(oldMethod, PsiModifier.DEFAULT, false);
RefactoringUtil.makeMethodAbstract(sourceClass, oldMethod);
}
}
else if (memberInfo.isToAbstract()) {
if (newMember.hasModifierProperty(PsiModifier.PRIVATE)) {
@@ -0,0 +1,7 @@
interface A {
default void fo<caret>o() {
System.out.println();
}
}
class B implements A {}
@@ -0,0 +1,7 @@
interface Test {
default void foo() {
System.out.println();
}
}
class B implements Test {}
@@ -0,0 +1,10 @@
interface Test {
void foo();
}
class B implements Test {
@Override
public void foo() {
System.out.println();
}
}
@@ -0,0 +1,8 @@
interface A {
}
class B implements A {
public void foo() {
System.out.println();
}
}
@@ -0,0 +1,7 @@
interface A {
default void f<caret>oo() {
System.out.println("");
}
}
interface B extends A {}
@@ -0,0 +1,7 @@
interface Test {
default void foo() {
System.out.println();
}
}
interface A extends Test {}
@@ -0,0 +1,10 @@
interface Test {
void foo();
}
interface A extends Test {
@Override
default void foo() {
System.out.println();
}
}
@@ -0,0 +1,8 @@
interface A {
}
interface B extends A {
default void foo() {
System.out.println("");
}
}
@@ -5,6 +5,6 @@ interface Base {
}
}
class Child implements Base {
abstract class Child implements Base {
public abstract void bar();
}
@@ -2,7 +2,7 @@ interface Test {
void bar();
}
class Child implements Test {
abstract class Child implements Test {
@Override
public abstract void bar();
}
@@ -0,0 +1,4 @@
interface A {
void fo<caret>o();
}
class B implements A {}
@@ -0,0 +1,5 @@
interface A {
}
abstract class B implements A {
public abstract void foo();
}
@@ -0,0 +1,7 @@
interface A {
static void f<caret>oo() {
System.out.println();
}
}
class B implements A {}
@@ -0,0 +1,8 @@
interface A {
}
class B implements A {
public static void foo() {
System.out.println();
}
}
@@ -0,0 +1,7 @@
interface A {
static void f<caret>oo() {
System.out.println();
}
}
interface B extends A {}
@@ -0,0 +1,8 @@
interface A {
}
interface B extends A {
static void foo() {
System.out.println();
}
}
@@ -64,7 +64,17 @@ public class PushDownTest extends LightRefactoringTestCase {
public void testInterfaceConstants() { doTest();}
public void testReferenceForMovedInnerClass() { doTest();}
public void testDefaultMethodToInterface() {doTest();}
public void testDefaultMethodToInterfaceKeepAbstract() {doTestImplements(true);}
public void testDefaultMethodToClass() {doTest();}
public void testDefaultMethodToClassKeepAbstract() { doTestImplements(true); }
public void testInterfaceStaticMethodToInterface() { doTest(); }
public void testInterfaceStaticMethodToClass() { doTest(); }
public void testInterfaceMethodToClass() { doTest();}
public void testInsertOverrideWhenKeepAbstract() throws Exception {
doTestImplements(true);
}