disable copy impls when interface extends; disable implement methods when methods with access problems exist (IDEA-93017)

(cherry picked from commit 3d50c0c08eaee71d14604ca9dfb0fcb2218c9b5c)
This commit is contained in:
anna
2012-11-22 15:04:53 +01:00
parent 1ecf71f23e
commit 6d2b2ced11
3 changed files with 21 additions and 1 deletions

View File

@@ -120,6 +120,7 @@ public class ImplementAbstractMethodAction extends BaseIntentionAction {
public boolean execute(@NotNull PsiElement element) {
if (element instanceof PsiClass) {
PsiClass aClass = (PsiClass) element;
if (aClass.isInterface()) return true;
final PsiMethod existingImplementation = findExistingImplementation(aClass, myMethod);
if (existingImplementation != null && !existingImplementation.hasModifierProperty(PsiModifier.ABSTRACT)) {
myHasExistingImplementations = true;
@@ -141,7 +142,7 @@ public class ImplementAbstractMethodAction extends BaseIntentionAction {
static PsiMethod findExistingImplementation(final PsiClass aClass, PsiMethod method) {
final PsiMethod[] methods = aClass.findMethodsByName(method.getName(), false);
for(PsiMethod candidate: methods) {
final PsiMethod[] superMethods = candidate.findSuperMethods(aClass);
final PsiMethod[] superMethods = candidate.findSuperMethods(false);
for(PsiMethod superMethod: superMethods) {
if (superMethod.equals(method)) {
return candidate;

View File

@@ -0,0 +1,11 @@
// "Use existing implementation of 'foo'" "false"
interface I {
void <caret>foo();
}
class IImpl implements I {
@Override
public void foo() {}
}
interface II extends I {}
class IImpl2 extends IImpl implements II {}

View File

@@ -0,0 +1,8 @@
// "Implement method 'foo'" "false"
abstract class Test {
public abstract void f<caret>oo();
}
class TImple extends Test {
private void foo(){}
}