Clover coverage report - PMD - 3.9 Coverage timestamp: Tue Dec 19 2006 09:38:44 EST FRAMES NO FRAMES |
file stats: | LOC: | 78 |  | Methods: | 8
| NCLOC: | 40 |  | Classes: | 1
Source file | Conditionals | Statements | Methods | TOTAL
Structure.java | 100% | 91.7% | 87.5% | 90.9% |

1 |  | /*
2 |  | * Created on 11.07.2004
3 |  | */
4 |  | package net.sourceforge.pmd.dfa;
5 |  |
6 |  | import net.sourceforge.pmd.ast.SimpleNode;
7 |  |
8 |  | import java.util.LinkedList;
9 |  | import java.util.List;
10 |  | import java.util.Stack;
11 |  |
12 |  |
13 |  | /**
14 |  | * @author raik
15 |  | * <p/>
16 |  | * Structure contains only raw data. A set of nodes wich represent a data flow
17 |  | * and 2 stacks to link the nodes to each other.
18 |  | */
19 |  | public class Structure {
20 |  |
21 |  | private LinkedList dataFlow = new LinkedList();
22 |  | private Stack braceStack = new Stack();
23 |  | private Stack continueBreakReturnStack = new Stack();
24 |  |
25 |  | /**
26 |  | * This class encapsulates the access to the DataFlowNode class. Is this worthwhile?
27 |  | * TODO I think it's too confusing to have the DataFlowNode constructor
28 |  | * add the created instance to the LinkedList. I think it'd be clearer if we did
29 |  | * that more "procedurally", i.e., create the object, then add it to the list.
30 |  | */
31 | 230 | public IDataFlowNode createNewNode(SimpleNode node) {
32 | 230 | return new DataFlowNode(node, this.dataFlow);
33 |  | }
34 |  |
35 | 45 | public IDataFlowNode createStartNode(int line) {
36 | 45 | return new StartOrEndDataFlowNode(this.dataFlow, line, true);
37 |  | }
38 |  |
39 | 45 | public IDataFlowNode createEndNode(int line) {
40 | 45 | return new StartOrEndDataFlowNode(this.dataFlow, line, false);
41 |  | }
42 |  |
43 | 216 | public IDataFlowNode getLast() {
44 | 216 | return (IDataFlowNode) this.dataFlow.getLast();
45 |  | }
46 |  |
47 | 0 | public IDataFlowNode getFirst() {
48 | 0 | return (IDataFlowNode) this.dataFlow.getFirst();
49 |  | }
50 |  |
51 |  | // ----------------------------------------------------------------------------
52 |  | // STACK FUNCTIONS
53 |  |
54 |  | /**
55 |  | * The braceStack contains all nodes which are important to link the data
56 |  | * flow nodes. The cbrStack contains continue, break, and return nodes.
57 |  | * There are 2 Stacks because the have to process differently.
58 |  | */
59 | 216 | protected void pushOnStack(int type, IDataFlowNode node) {
60 | 216 | StackObject obj = new StackObject(type, node);
61 | 216 | if (type == NodeType.RETURN_STATEMENT || type == NodeType.BREAK_STATEMENT || type == NodeType.CONTINUE_STATEMENT) {
62 |  | // ugly solution - stores the type information in two ways
63 | 6 | continueBreakReturnStack.push(obj);
64 |  | } else {
65 | 210 | braceStack.push(obj);
66 |  | }
67 | 216 | ((DataFlowNode) node).setType(type);
68 |  | }
69 |  |
70 | 45 | public List getBraceStack() {
71 | 45 | return braceStack;
72 |  | }
73 |  |
74 | 45 | public List getContinueBreakReturnStack() {
75 | 45 | return continueBreakReturnStack;
76 |  | }
77 |  |
78 |  | }