mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
generate method: insert Override when super method is accessible (IDEA-189949)
This commit is contained in:
@@ -719,7 +719,7 @@ public class GenerateMembersUtil {
|
||||
|
||||
if (JavaCodeStyleSettings.getInstance(targetClass.getContainingFile()).INSERT_OVERRIDE_ANNOTATION) {
|
||||
PsiMethod superMethod = targetClass.findMethodBySignature(generated, true);
|
||||
if (superMethod != null && superMethod.getContainingClass() != targetClass) {
|
||||
if (superMethod != null && superMethod.getContainingClass() != targetClass && PsiUtil.isAccessible(superMethod, targetClass, null)) {
|
||||
OverrideImplementUtil.annotateOnOverrideImplement(generated, targetClass, superMethod, true);
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package a;
|
||||
|
||||
public class A {
|
||||
int getFoo();
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package b;
|
||||
import a.A;
|
||||
class B extends A {
|
||||
int foo;
|
||||
|
||||
public int getFoo() {
|
||||
return foo;
|
||||
}
|
||||
|
||||
public void setFoo(int foo) {
|
||||
this.foo = foo;
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package a;
|
||||
|
||||
public class A {
|
||||
int getFoo();
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package b;
|
||||
import a.A;
|
||||
class B extends A {
|
||||
int foo;
|
||||
}
|
||||
@@ -61,6 +61,10 @@ public class EncapsulateFieldsTest extends MultiFileTestCase {
|
||||
doTest("i", "B.A", null);
|
||||
}
|
||||
|
||||
public void testInaccessibleSuperMethod() {
|
||||
doTest("foo", "b.B", null);
|
||||
}
|
||||
|
||||
public void testHideOuterclassMethod() {
|
||||
doTest("i", "A.B", "There is already a method <b><code>A.getI()</code></b> which would be hidden by generated getter");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user