mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
disable constructor matching super when appropriate candidate already present
IDEA-113427
This commit is contained in:
+17
-2
@@ -61,8 +61,23 @@ public class CreateConstructorMatchingSuperFix extends BaseIntentionAction {
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
if (!myClass.isValid() || !myClass.getManager().isInProject(myClass)) return false;
|
||||
setText(QuickFixBundle.message("create.constructor.matching.super"));
|
||||
return true;
|
||||
PsiClass base = myClass.getSuperClass();
|
||||
if (base == null) return false;
|
||||
PsiSubstitutor substitutor = TypeConversionUtil.getSuperClassSubstitutor(base, myClass, PsiSubstitutor.EMPTY);
|
||||
for (PsiMethod baseConstructor: base.getConstructors()) {
|
||||
if (PsiUtil.isAccessible(baseConstructor, myClass, null)) {
|
||||
PsiMethod derived = GenerateMembersUtil.substituteGenericMethod(baseConstructor, substitutor, myClass);
|
||||
String className = myClass.getName();
|
||||
LOG.assertTrue(className != null);
|
||||
derived.setName(className);
|
||||
if (myClass.findMethodBySignature(derived, false) == null) {
|
||||
setText(QuickFixBundle.message("create.constructor.matching.super"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Create constructor matching super" "false"
|
||||
class A {
|
||||
public A(int i) {
|
||||
}
|
||||
}
|
||||
class B extends A {
|
||||
public B<caret>(int i) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user