summaryrefslogtreecommitdiff
path: root/src/main/java/org/javacs/WarnUnused.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/javacs/WarnUnused.java')
-rw-r--r--src/main/java/org/javacs/WarnUnused.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main/java/org/javacs/WarnUnused.java b/src/main/java/org/javacs/WarnUnused.java
index 8263f4a..35c7165 100644
--- a/src/main/java/org/javacs/WarnUnused.java
+++ b/src/main/java/org/javacs/WarnUnused.java
@@ -37,6 +37,10 @@ class WarnUnused extends TreePathScanner<Void, Void> {
return t.getModifiers().getFlags().contains(Modifier.PRIVATE);
}
+ boolean isEmptyConstructor(MethodTree t) {
+ return t.getParameters().isEmpty() && trees.getElement(getCurrentPath()).getKind() == ElementKind.CONSTRUCTOR;
+ }
+
@Override
public Void visitVariable(VariableTree t, Void __) {
if (isPrivate(t) || isLocal(t)) {
@@ -46,6 +50,14 @@ class WarnUnused extends TreePathScanner<Void, Void> {
}
@Override
+ public Void visitMethod(MethodTree t, Void __) {
+ if (isPrivate(t) && !isEmptyConstructor(t)) {
+ declared.add(current());
+ }
+ return super.visitMethod(t, null);
+ }
+
+ @Override
public Void visitIdentifier(IdentifierTree t, Void __) {
used.add(current());
return super.visitIdentifier(t, null);