1 /***
2 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 */
4 package net.sourceforge.pmd.symboltable;
5
6 import net.sourceforge.pmd.ast.ASTCompilationUnit;
7 import net.sourceforge.pmd.ast.ASTPrimaryExpression;
8 import net.sourceforge.pmd.ast.JavaParserVisitorAdapter;
9
10 import java.util.Iterator;
11
12 public class SymbolFacade extends JavaParserVisitorAdapter {
13
14 public void initializeWith(ASTCompilationUnit node) {
15
16 BasicScopeCreationVisitor sc = new BasicScopeCreationVisitor(new BasicScopeFactory());
17 node.jjtAccept(sc, null);
18
19
20 DeclarationFinder df = new DeclarationFinder();
21 node.jjtAccept(df, null);
22
23
24 node.jjtAccept(this, null);
25 }
26
27 public Object visit(ASTPrimaryExpression node, Object data) {
28 NameOccurrences qualifiedNames = new NameOccurrences(node);
29 NameDeclaration decl = null;
30 for (Iterator i = qualifiedNames.iterator(); i.hasNext();) {
31 NameOccurrence occ = (NameOccurrence) i.next();
32 Search search = new Search(occ);
33 if (decl == null) {
34
35 search.execute();
36 decl = search.getResult();
37 if (decl == null) {
38
39
40
41 break;
42 }
43 } else {
44
45 search.execute(decl.getScope());
46 decl = search.getResult();
47 }
48 }
49 return super.visit(node, data);
50 }
51
52 }