Clover coverage report - PMD - 3.7 Coverage timestamp: Wed May 31 2006 09:25:59 EDT FRAMES NO FRAMES |

file stats: | LOC: | 42 |  | Methods: | 5
| NCLOC: | 32 |  | Classes: | 1

Source file | Conditionals | Statements | Methods | TOTAL
Search.java | 56.2% | 73.7% | 100% | 70% |

1 |  | /**
2 |  | * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 |  | */
4 |  | package net.sourceforge.pmd.symboltable;
5 |  |
6 |  | public class Search {
7 |  | private static final boolean TRACE = false;
8 |  |
9 |  | private NameOccurrence occ;
10 |  | private NameDeclaration decl;
11 |  |
12 | 1915 | public Search(NameOccurrence occ) {
13 | 0 | if (TRACE) System.out.println("new search for " + (occ.isMethodOrConstructorInvocation() ? "method" : "variable") + " " + occ);
14 | 1915 | this.occ = occ;
15 |  | }
16 |  |
17 | 1483 | public void execute() {
18 | 1483 | decl = searchUpward(occ, occ.getLocation().getScope());
19 | 0 | if (TRACE) System.out.println("found " + decl);
20 |  | }
21 |  |
22 | 432 | public void execute(Scope startingScope) {
23 | 432 | decl = searchUpward(occ, startingScope);
24 | 0 | if (TRACE) System.out.println("found " + decl);
25 |  | }
26 |  |
27 | 1915 | public NameDeclaration getResult() {
28 | 1915 | return decl;
29 |  | }
30 |  |
31 | 5118 | private NameDeclaration searchUpward(NameOccurrence nameOccurrence, Scope scope) {
32 | 5118 | if (!scope.contains(nameOccurrence) && scope.getParent() != null) {
33 | 0 | if (TRACE) System.out.println("moving up fm " + scope + " to " + scope.getParent());
34 | 3203 | return searchUpward(nameOccurrence, scope.getParent());
35 |  | }
36 | 1915 | if (scope.contains(nameOccurrence)) {
37 | 0 | if (TRACE) System.out.println("found it!");
38 | 1093 | return scope.addVariableNameOccurrence(nameOccurrence);
39 |  | }
40 | 822 | return null;
41 |  | }
42 |  | }