push down from interface to abstract class fixed (IDEA-82286)

This commit is contained in:
anna
2012-03-12 12:43:05 +01:00
parent e0e2622efd
commit 3c5d7a568d
4 changed files with 23 additions and 2 deletions
@@ -356,11 +356,14 @@ public class PushDownProcessor extends BaseRefactoringProcessor {
}
else if (member instanceof PsiMethod) {
PsiMethod method = (PsiMethod)member;
final PsiMethod methodBySignature = targetClass.findMethodBySignature(method, false);
if (methodBySignature == null) {
final boolean wasInterface = myClass.isInterface();
newMember = (PsiMethod)targetClass.add(method);
if (memberInfo.isToAbstract()) {
if (wasInterface) {
PsiUtil.setModifierProperty(newMember, PsiModifier.ABSTRACT, true);
PsiUtil.setModifierProperty(newMember, PsiModifier.PUBLIC, true);
} else if (memberInfo.isToAbstract()) {
if (newMember.hasModifierProperty(PsiModifier.PRIVATE)) {
PsiUtil.setModifierProperty(newMember, PsiModifier.PROTECTED, true);
}
@@ -0,0 +1,7 @@
abstract class StraightLine implements Inline {
}
interface Inline {
void g<caret>o(); // inline this method
}
@@ -0,0 +1,7 @@
abstract class StraightLine implements Inline {
public abstract void go(); // inline this method
}
interface Inline {
}
@@ -111,6 +111,10 @@ public class PushDownTest extends LightRefactoringTestCase {
doTest();
}
public void testMethodFromInterfaceToAbstractClass() throws Exception {
doTest();
}
public void testSameClassInterface() throws Exception {
final String filePath = "/refactoring/pushDown/" + getTestName(false) + ".java";
configureByFile(filePath);