1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
16
|
|
17
|
|
18
|
|
19
|
|
20
|
|
21
|
|
22
|
|
23
|
|
24
|
|
25
|
|
26
|
|
27
|
|
28
|
package org.momut.ooas.visitors.analysis;
|
29
|
|
30
|
import org.momut.ooas.ast.identifiers.AttributeIdentifier;
|
31
|
import org.momut.ooas.ast.identifiers.LocalVariableIdentifier;
|
32
|
import org.momut.ooas.ast.identifiers.MainModule;
|
33
|
import org.momut.ooas.ast.identifiers.MethodIdentifier;
|
34
|
import org.momut.ooas.ast.identifiers.Module;
|
35
|
import org.momut.ooas.ast.identifiers.NamedActionIdentifier;
|
36
|
import org.momut.ooas.ast.identifiers.TypeIdentifier;
|
37
|
import org.momut.ooas.ast.statements.AbortStatement;
|
38
|
import org.momut.ooas.ast.statements.Assignment;
|
39
|
import org.momut.ooas.ast.statements.BreakStatement;
|
40
|
import org.momut.ooas.ast.statements.Call;
|
41
|
import org.momut.ooas.ast.statements.GuardedCommand;
|
42
|
import org.momut.ooas.ast.statements.KillStatement;
|
43
|
import org.momut.ooas.ast.statements.NondetBlock;
|
44
|
import org.momut.ooas.ast.statements.PrioBlock;
|
45
|
import org.momut.ooas.ast.statements.SeqBlock;
|
46
|
import org.momut.ooas.ast.statements.SkipStatement;
|
47
|
import org.momut.ooas.ast.types.OoActionSystemType;
|
48
|
import org.momut.ooas.parser.ParserMessage;
|
49
|
import org.momut.ooas.parser.ParserState;
|
50
|
import org.momut.ooas.visitors.OoaCompleteAstTraversalVisitor;
|
51
|
|
52
|
public final class OoaPrintMetricsVisitor extends OoaCompleteAstTraversalVisitor {
|
53
|
|
54
|
protected int m_modules = 0;
|
55
|
protected int m_actions = 0;
|
56
|
protected int m_methods = 0;
|
57
|
protected int m_statements = 0;
|
58
|
protected int m_actionSystems = 0;
|
59
|
protected int m_attributes = 0;
|
60
|
protected int m_namedTypes = 0;
|
61
|
protected int m_blocks = 0;
|
62
|
protected int m_localVars = 0;
|
63
|
|
64
|
public int getNumberOfModules() {return m_modules;}
|
65
|
public int getNumberOfActions() {return m_actions;}
|
66
|
public int getNumberOfMethods() {return m_methods;}
|
67
|
public int getNumberOfStatements() {return m_statements;}
|
68
|
public int getNumberOfActionSystems() {return m_actionSystems;}
|
69
|
public int getNumberOfGlobalVariables(){return m_attributes;}
|
70
|
|
71
|
@Override
|
72
|
public String toString() {
|
73
|
return String.format("# Modules: %s, # Actions: %s, # Methods: %s, # Statements: %s, # ActionsSystems: %s, # Attributes: %s, # Named Types %s, # Blocks: %s, # Local Vars: %s",
|
74
|
m_modules, m_actions, m_methods, m_statements, m_actionSystems, m_attributes, m_namedTypes, m_blocks, m_localVars);
|
75
|
}
|
76
|
|
77
|
@Override
|
78
|
public void done() {
|
79
|
m_ParserState.AddMessage(new ParserMessage(m_ParserState.filename, 0,0, "OOAS Metrics:\n\t" + toString()));
|
80
|
}
|
81
|
|
82
|
@Override
|
83
|
public void visit(LocalVariableIdentifier localVariableIdentifier) {
|
84
|
m_localVars++;
|
85
|
super.visit(localVariableIdentifier);
|
86
|
}
|
87
|
|
88
|
@Override
|
89
|
public void visit(NondetBlock nondetBlock) {
|
90
|
m_blocks++;
|
91
|
super.visit(nondetBlock);
|
92
|
}
|
93
|
@Override
|
94
|
public void visit(PrioBlock prioBlock) {
|
95
|
m_blocks++;
|
96
|
super.visit(prioBlock);
|
97
|
}
|
98
|
@Override
|
99
|
public void visit(SeqBlock seqBlock) {
|
100
|
m_blocks++;
|
101
|
super.visit(seqBlock);
|
102
|
}
|
103
|
|
104
|
@Override
|
105
|
public void visit(TypeIdentifier typeIdentifier) {
|
106
|
m_namedTypes++;
|
107
|
super.visit(typeIdentifier);
|
108
|
}
|
109
|
|
110
|
@Override
|
111
|
public void visit(AbortStatement abortStatement) {
|
112
|
m_statements++;
|
113
|
super.visit(abortStatement);
|
114
|
}
|
115
|
|
116
|
@Override
|
117
|
public void visit(Assignment assignment) {
|
118
|
m_statements++;
|
119
|
super.visit(assignment);
|
120
|
}
|
121
|
|
122
|
@Override
|
123
|
public void visit(AttributeIdentifier attributeIdentifier) {
|
124
|
m_attributes++;
|
125
|
super.visit(attributeIdentifier);
|
126
|
}
|
127
|
|
128
|
@Override
|
129
|
public void visit(BreakStatement breakStatement) {
|
130
|
m_statements++;
|
131
|
super.visit(breakStatement);
|
132
|
}
|
133
|
|
134
|
@Override
|
135
|
public void visit(Call call) {
|
136
|
m_statements++;
|
137
|
super.visit(call);
|
138
|
}
|
139
|
|
140
|
@Override
|
141
|
public void visit(GuardedCommand guardedCommand) {
|
142
|
m_statements++;
|
143
|
super.visit(guardedCommand);
|
144
|
}
|
145
|
|
146
|
@Override
|
147
|
public void visit(KillStatement killStatement) {
|
148
|
m_statements++;
|
149
|
super.visit(killStatement);
|
150
|
}
|
151
|
|
152
|
@Override
|
153
|
public void visit(MainModule mainModule) {
|
154
|
m_modules++;
|
155
|
super.visit(mainModule);
|
156
|
}
|
157
|
|
158
|
@Override
|
159
|
public void visit(MethodIdentifier methodIdentifier) {
|
160
|
m_methods++;
|
161
|
super.visit(methodIdentifier);
|
162
|
}
|
163
|
|
164
|
@Override
|
165
|
public void visit(Module module) {
|
166
|
m_modules++;
|
167
|
super.visit(module);
|
168
|
}
|
169
|
|
170
|
@Override
|
171
|
public void visit(NamedActionIdentifier namedActionIdentifier) {
|
172
|
m_actions++;
|
173
|
super.visit(namedActionIdentifier);
|
174
|
}
|
175
|
|
176
|
@Override
|
177
|
public void visit(OoActionSystemType ooActionSystemType) {
|
178
|
m_actionSystems++;
|
179
|
super.visit(ooActionSystemType);
|
180
|
}
|
181
|
|
182
|
@Override
|
183
|
public void visit(SkipStatement skipStatement) {
|
184
|
m_statements++;
|
185
|
super.visit(skipStatement);
|
186
|
}
|
187
|
|
188
|
public OoaPrintMetricsVisitor(ParserState aState) {
|
189
|
super(aState, false);
|
190
|
}
|
191
|
|
192
|
}
|