1 package net.sourceforge.pmd.symboltable; 2 3 import net.sourceforge.pmd.ast.ASTPrimaryExpression; 4 import net.sourceforge.pmd.ast.JavaParserVisitorAdapter; 5 6 import java.util.Iterator ; 7 import java.util.List ; 8 9 public class OccurrenceFinder extends JavaParserVisitorAdapter { 10 11 public Object visit(ASTPrimaryExpression node, Object data) { 12 NameFinder nameFinder = new NameFinder(node); 13 14 NameDeclaration decl = null; 17 18 List names = nameFinder.getNames(); 19 for (Iterator i = names.iterator(); i.hasNext();) { 20 NameOccurrence occ = (NameOccurrence) i.next(); 21 Search search = new Search(occ); 22 if (decl == null) { 23 search.execute(); 25 decl = search.getResult(); 26 if (decl == null) { 27 break; 31 } 32 } else { 33 search.execute(decl.getScope()); 35 decl = search.getResult(); 36 } 37 } 38 return super.visit(node, data); 39 } 40 41 } 42 | Popular Tags |