Clover coverage report - PMD - 3.9 Coverage timestamp: Tue Dec 19 2006 09:38:44 EST FRAMES NO FRAMES |
file stats: | LOC: | 76 |  | Methods: | 12
| NCLOC: | 56 |  | Classes: | 1
Source file | Conditionals | Statements | Methods | TOTAL
VariableNameDeclaration.java | 100% | 89.5% | 83.3% | 88.6% |

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.ASTFormalParameter;
7 |  | import net.sourceforge.pmd.ast.ASTPrimitiveType;
8 |  | import net.sourceforge.pmd.ast.ASTReferenceType;
9 |  | import net.sourceforge.pmd.ast.ASTType;
10 |  | import net.sourceforge.pmd.ast.ASTVariableDeclaratorId;
11 |  | import net.sourceforge.pmd.ast.AccessNode;
12 |  | import net.sourceforge.pmd.ast.Dimensionable;
13 |  | import net.sourceforge.pmd.ast.SimpleNode;
14 |  |
15 |  | public class VariableNameDeclaration extends AbstractNameDeclaration {
16 |  |
17 | 1458 | public VariableNameDeclaration(ASTVariableDeclaratorId node) {
18 | 1458 | super(node);
19 |  | }
20 |  |
21 | 446 | public Scope getScope() {
22 | 446 | return node.getScope().getEnclosingClassScope();
23 |  | }
24 |  |
25 | 51 | public boolean isArray() {
26 | 51 | ASTVariableDeclaratorId astVariableDeclaratorId = (ASTVariableDeclaratorId) node;
27 | 51 | ASTType typeNode = astVariableDeclaratorId.getTypeNode();
28 | 51 | return ((Dimensionable) (typeNode.jjtGetParent())).isArray();
29 |  | }
30 |  |
31 | 1 | public boolean isExceptionBlockParameter() {
32 | 1 | return ((ASTVariableDeclaratorId) node).isExceptionBlockParameter();
33 |  | }
34 |  |
35 | 321 | public boolean isPrimitiveType() {
36 | 321 | return getAccessNodeParent().jjtGetChild(0).jjtGetChild(0) instanceof ASTPrimitiveType;
37 |  | }
38 |  |
39 | 317 | public String getTypeImage() {
40 | 317 | if (isPrimitiveType()) {
41 | 8 | return ((SimpleNode) (getAccessNodeParent().jjtGetChild(0).jjtGetChild(0))).getImage();
42 |  | }
43 | 309 | return ((SimpleNode) getAccessNodeParent().jjtGetChild(0).jjtGetChild(0).jjtGetChild(0)).getImage();
44 |  | }
45 |  |
46 |  | /**
47 |  | * Note that an array of primitive types (int[]) is a reference type.
48 |  | */
49 | 8 | public boolean isReferenceType() {
50 | 8 | return getAccessNodeParent().jjtGetChild(0).jjtGetChild(0) instanceof ASTReferenceType;
51 |  | }
52 |  |
53 | 886 | public AccessNode getAccessNodeParent() {
54 | 886 | if (node.jjtGetParent() instanceof ASTFormalParameter) {
55 | 120 | return (AccessNode) node.jjtGetParent();
56 |  | }
57 | 766 | return (AccessNode) node.jjtGetParent().jjtGetParent();
58 |  | }
59 |  |
60 | 0 | public ASTVariableDeclaratorId getDeclaratorId() {
61 | 0 | return (ASTVariableDeclaratorId) node;
62 |  | }
63 |  |
64 | 2 | public boolean equals(Object o) {
65 | 2 | VariableNameDeclaration n = (VariableNameDeclaration) o;
66 | 2 | return n.node.getImage().equals(node.getImage());
67 |  | }
68 |  |
69 | 5275 | public int hashCode() {
70 | 5275 | return node.getImage().hashCode();
71 |  | }
72 |  |
73 | 0 | public String toString() {
74 | 0 | return "Variable: image = '" + node.getImage() + "', line = " + node.getBeginLine();
75 |  | }
76 |  | }