Clover coverage report - PMD - 3.9 Coverage timestamp: Tue Dec 19 2006 09:38:44 EST 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 | 3537 | public Object visit(ASTPrimaryExpression node, Object data) {
12 | 3537 | NameFinder nameFinder = new NameFinder(node);
13 |  |
14 |  | // Maybe do some sort of State pattern thingy for when NameDeclaration
15 |  | // is null/not null?
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 |  | // doing the first name lookup
24 | 1830 | search.execute();
25 | 1830 | decl = search.getResult();
26 | 1830 | 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 | 598 | break;
31 |  | }
32 |  | } else {
33 |  | // now we've got a scope we're starting with, so work from there
34 | 481 | search.execute(decl.getScope());
35 | 481 | decl = search.getResult();
36 |  | }
37 |  | }
38 | 3537 | return super.visit(node, data);
39 |  | }
40 |  |
41 |  | }