Fix issue #527
This commit is contained in:
@ -12,6 +12,7 @@ import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTAnnotation;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTEnumDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTName;
|
||||
|
||||
@ -59,6 +60,12 @@ public class AbstractLombokAwareRule extends AbstractJavaRule {
|
||||
return super.visit(node, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(ASTEnumDeclaration node, Object data) {
|
||||
classHasLombokAnnotation = hasLombokAnnotation(node);
|
||||
return super.visit(node, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether there have been class level Lombok annotations found.
|
||||
* Note: this can only be queried after the class declaration node has been
|
||||
|
@ -605,4 +605,24 @@ public final class Test {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>#527 [java] Lombok getter annotation on enum is not recognized correctly</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum Foo {
|
||||
BAR(1);
|
||||
|
||||
private final int number;
|
||||
|
||||
Foo(final int number) {
|
||||
this.number = number;
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
</test-data>
|
||||
|
Reference in New Issue
Block a user