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

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 | 1242 | public VariableNameDeclaration(ASTVariableDeclaratorId node) {
18 | 1242 | super(node);
19 |  | }
20 |  |
21 | 401 | public Scope getScope() {
22 | 401 | return node.getScope().getEnclosingClassScope();
23 |  | }
24 |  |
25 | 45 | public boolean isArray() {
26 | 45 | ASTVariableDeclaratorId astVariableDeclaratorId = (ASTVariableDeclaratorId) node;
27 | 45 | ASTType typeNode = astVariableDeclaratorId.getTypeNode();
28 | 45 | return ((Dimensionable) (typeNode.jjtGetParent())).isArray();
29 |  | }
30 |  |
31 | 1 | public boolean isExceptionBlockParameter() {
32 | 1 | return ((ASTVariableDeclaratorId) node).isExceptionBlockParameter();
33 |  | }
34 |  |
35 | 303 | public boolean isPrimitiveType() {
36 | 303 | return getAccessNodeParent().jjtGetChild(0).jjtGetChild(0) instanceof ASTPrimitiveType;
37 |  | }
38 |  |
39 | 302 | public String getTypeImage() {
40 | 302 | if (isPrimitiveType()) {
41 | 9 | return ((SimpleNode) (getAccessNodeParent().jjtGetChild(0).jjtGetChild(0))).getImage();
42 |  | }
43 | 293 | 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 | 756 | public AccessNode getAccessNodeParent() {
54 | 756 | if (node.jjtGetParent() instanceof ASTFormalParameter) {
55 | 110 | return (AccessNode) node.jjtGetParent();
56 |  | }
57 | 646 | 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 | 4612 | public int hashCode() {
70 | 4612 | return node.getImage().hashCode();
71 |  | }
72 |  |
73 | 0 | public String toString() {
74 | 0 | return "Variable: image = '" + node.getImage() + "', line = " + node.getBeginLine();
75 |  | }
76 |  | }