mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
push down: order abstract/default/static (IDEA-148492)
This commit is contained in:
+9
-3
@@ -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 {}
|
||||
+10
@@ -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 {}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
interface Test {
|
||||
default void foo() {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
interface A extends Test {}
|
||||
+10
@@ -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();
|
||||
}
|
||||
|
||||
+1
-1
@@ -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 {}
|
||||
+8
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user