01 /**
02 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
03 */
04 package net.sourceforge.pmd.lang.java.rule;
05
06 import net.sourceforge.pmd.lang.ast.Node;
07 import net.sourceforge.pmd.lang.java.ast.ASTFieldDeclaration;
08 import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId;
09 import net.sourceforge.pmd.lang.java.symboltable.NameOccurrence;
10
11 //FUTURE This is not referenced by any RuleSet?
12 public class SymbolTableTestRule extends AbstractJavaRule {
13
14 @Override
15 public Object visit(ASTFieldDeclaration node,Object data) {
16 for(ASTVariableDeclaratorId declaration: node.findDescendantsOfType(ASTVariableDeclaratorId.class)) {
17 for (NameOccurrence no: declaration.getUsages()) {
18 Node location = no.getLocation();
19 System.out.println(declaration.getImage() + " is used here: " + location.getImage());
20 }
21 }
22 return data;
23 }
24 }
|