Clover coverage report - PMD - 3.7 Coverage timestamp: Wed May 31 2006 09:25:59 EDT FRAMES NO FRAMES |
file stats: | LOC: | 41 |  | Methods: | 1
| NCLOC: | 27 |  | Classes: | 1
Source file | Conditionals | Statements | Methods | TOTAL
OccurrenceFinder.java | 100% | 100% | 100% | 100% |

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 | 2940 | public Object visit(ASTPrimaryExpression node, Object data) {
12 | 2940 | NameFinder nameFinder = new NameFinder(node);
13 |  |
14 |  | // Maybe do some sort of State pattern thingy for when NameDeclaration
15 |  | // is null/not null?
16 | 2940 | NameDeclaration decl = null;
17 |  |
18 | 2940 | List names = nameFinder.getNames();
19 | 2940 | for (Iterator i = names.iterator(); i.hasNext();) {
20 | 1915 | NameOccurrence occ = (NameOccurrence) i.next();
21 | 1915 | Search search = new Search(occ);
22 | 1915 | if (decl == null) {
23 |  | // doing the first name lookup
24 | 1483 | search.execute();
25 | 1483 | decl = search.getResult();
26 | 1483 | if (decl == null) {
27 |  | // we can't find it, so just give up
28 |  | // when we decide to do full symbol resolution
29 |  | // force this to either find a symbol or throw a SymbolNotFoundException
30 | 441 | break;
31 |  | }
32 |  | } else {
33 |  | // now we've got a scope we're starting with, so work from there
34 | 432 | search.execute(decl.getScope());
35 | 432 | decl = search.getResult();
36 |  | }
37 |  | }
38 | 2940 | return super.visit(node, data);
39 |  | }
40 |  |
41 |  | }