01: package net.sourceforge.pmd.rules;
02:
03: import net.sourceforge.pmd.AbstractRule;
04: import net.sourceforge.pmd.ast.ASTClassOrInterfaceDeclaration;
05: import net.sourceforge.pmd.ast.ASTMethodDeclarator;
06:
07: import java.util.List;
08:
09: public class MethodWithSameNameAsEnclosingClass extends AbstractRule {
10:
11: public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
12: List<ASTMethodDeclarator> methods = node
13: .findChildrenOfType(ASTMethodDeclarator.class);
14: for (ASTMethodDeclarator m : methods) {
15: if (m.hasImageEqualTo(node.getImage())) {
16: addViolation(data, m);
17: }
18: }
19: return super.visit(node, data);
20: }
21: }
|