mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
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:
@@ -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;
|
||||
|
||||
@@ -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 {}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Implement method 'foo'" "false"
|
||||
abstract class Test {
|
||||
public abstract void f<caret>oo();
|
||||
}
|
||||
|
||||
class TImple extends Test {
|
||||
private void foo(){}
|
||||
}
|
||||
Reference in New Issue
Block a user