mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
empty methods hierarchy: warn about deepest methods, top empty could be of use (IDEA-146409)
This commit is contained in:
+2
-2
@@ -83,8 +83,8 @@ public class EmptyMethodInspection extends GlobalJavaBatchInspectionTool {
|
||||
|
||||
String message = null;
|
||||
boolean needToDeleteHierarchy = false;
|
||||
RefMethod refSuper = findSuperWithBody(refMethod);
|
||||
if (refMethod.isOnlyCallsSuper() && !refMethod.isFinal()) {
|
||||
RefMethod refSuper = findSuperWithBody(refMethod);
|
||||
final RefJavaUtil refUtil = RefJavaUtil.getInstance();
|
||||
if (refSuper != null && Comparing.strEqual(refMethod.getAccessModifier(), refSuper.getAccessModifier())){
|
||||
if (Comparing.strEqual(refSuper.getAccessModifier(), PsiModifier.PROTECTED) //protected modificator gives access to method in another package
|
||||
@@ -112,7 +112,7 @@ public class EmptyMethodInspection extends GlobalJavaBatchInspectionTool {
|
||||
|
||||
message = InspectionsBundle.message("inspection.empty.method.problem.descriptor1");
|
||||
}
|
||||
else if (areAllImplementationsEmpty(refMethod)) {
|
||||
else if (areAllImplementationsEmpty(refMethod) && refSuper == null) {
|
||||
if (refMethod.hasBody()) {
|
||||
if (refMethod.getDerivedMethods().isEmpty()) {
|
||||
if (refMethod.getSuperMethods().isEmpty()) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Derived.java</file>
|
||||
<line>15</line>
|
||||
<description>Empty method overrides empty method</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package p2;
|
||||
|
||||
class A {
|
||||
public void foo(){
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
@Override
|
||||
public void foo() {}
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
@Override
|
||||
public void foo() {}
|
||||
}
|
||||
@@ -49,4 +49,8 @@ public class EmptyMethodTest extends InspectionTestCase {
|
||||
public void testSuperWithoutSync() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testEmptyMethodsHierarchy() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user