can be final: don't suggest private methods

This commit is contained in:
Anna.Kozlova
2018-12-20 19:11:04 +01:00
parent 06258d1ee0
commit 4012d7e874
2 changed files with 4 additions and 0 deletions
@@ -133,6 +133,7 @@ public class CanBeFinalInspection extends GlobalJavaBatchInspectionTool {
else if (refElement instanceof RefMethod) {
RefMethod refMethod = (RefMethod)refElement;
if (refMethod.getOwnerClass().isFinal()) return null;
if (psiMember.hasModifierProperty(PsiModifier.PRIVATE)) return null;
if (!isReportMethods()) return null;
psiIdentifier = ((PsiMethod)psiMember).getNameIdentifier();
}
@@ -1,6 +1,9 @@
// A.java
class A implements Runnable {
public void run() {
a();
}
private void a() {}
}