|
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 |
3537
| public Object visit(ASTPrimaryExpression node, Object data) {
|
|
12 |
3537
| NameFinder nameFinder = new NameFinder(node);
|
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
3537
| NameDeclaration decl = null;
|
|
17 |
| |
|
18 |
3537
| List names = nameFinder.getNames();
|
|
19 |
3537
| for (Iterator i = names.iterator(); i.hasNext();) {
|
|
20 |
2311
| NameOccurrence occ = (NameOccurrence) i.next();
|
|
21 |
2311
| Search search = new Search(occ);
|
|
22 |
2311
| if (decl == null) {
|
|
23 |
| |
|
24 |
1830
| search.execute();
|
|
25 |
1830
| decl = search.getResult();
|
|
26 |
1830
| if (decl == null) {
|
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
598
| break;
|
|
31 |
| } |
|
32 |
| } else { |
|
33 |
| |
|
34 |
481
| search.execute(decl.getScope());
|
|
35 |
481
| decl = search.getResult();
|
|
36 |
| } |
|
37 |
| } |
|
38 |
3537
| return super.visit(node, data);
|
|
39 |
| } |
|
40 |
| |
|
41 |
| } |