Package: StatementFinder

StatementFinder

nameinstructionbranchcomplexitylinemethod
StatementFinder(IInterpreterAssistantFactory)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
caseAAlwaysStm(AAlwaysStm, Integer)
M: 29 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
caseAAnnotatedStm(AAnnotatedStm, Integer)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
caseAAtomicStm(AAtomicStm, Integer)
M: 33 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
caseACasesStm(ACasesStm, Integer)
M: 34 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
caseACyclesStm(ACyclesStm, Integer)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
caseADurationStm(ADurationStm, Integer)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
caseAElseIfStm(AElseIfStm, Integer)
M: 17 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
caseAForAllStm(AForAllStm, Integer)
M: 17 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
caseAForIndexStm(AForIndexStm, Integer)
M: 17 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
caseAForPatternBindStm(AForPatternBindStm, Integer)
M: 17 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
caseAIfStm(AIfStm, Integer)
M: 57 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 14 C: 0
0%
M: 1 C: 0
0%
caseALetBeStStm(ALetBeStStm, Integer)
M: 17 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
caseALetStm(ALetStm, Integer)
M: 29 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
caseATixeStm(ATixeStm, Integer)
M: 46 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 12 C: 0
0%
M: 1 C: 0
0%
caseATrapStm(ATrapStm, Integer)
M: 29 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
caseAWhileStm(AWhileStm, Integer)
M: 17 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
createNewReturnValue(INode, Integer)
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
createNewReturnValue(Object, Integer)
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
defaultPStm(PStm, Integer)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
defaultSSimpleBlockStm(SSimpleBlockStm, Integer)
M: 34 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
findStatementBaseCase(PStm, int)
M: 9 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: package org.overture.interpreter.utilities.statement;
2:
3: import org.overture.ast.analysis.AnalysisException;
4: import org.overture.ast.analysis.QuestionAnswerAdaptor;
5: import org.overture.ast.node.INode;
6: import org.overture.ast.statements.AAlwaysStm;
7: import org.overture.ast.statements.AAnnotatedStm;
8: import org.overture.ast.statements.AAssignmentStm;
9: import org.overture.ast.statements.AAtomicStm;
10: import org.overture.ast.statements.ACaseAlternativeStm;
11: import org.overture.ast.statements.ACasesStm;
12: import org.overture.ast.statements.ACyclesStm;
13: import org.overture.ast.statements.ADurationStm;
14: import org.overture.ast.statements.AElseIfStm;
15: import org.overture.ast.statements.AForAllStm;
16: import org.overture.ast.statements.AForIndexStm;
17: import org.overture.ast.statements.AForPatternBindStm;
18: import org.overture.ast.statements.AIfStm;
19: import org.overture.ast.statements.ALetBeStStm;
20: import org.overture.ast.statements.ALetStm;
21: import org.overture.ast.statements.ATixeStm;
22: import org.overture.ast.statements.ATixeStmtAlternative;
23: import org.overture.ast.statements.ATrapStm;
24: import org.overture.ast.statements.AWhileStm;
25: import org.overture.ast.statements.PStm;
26: import org.overture.ast.statements.SSimpleBlockStm;
27: import org.overture.interpreter.assistant.IInterpreterAssistantFactory;
28:
29: /***************************************
30: * This method finds a statement type in a model.
31: *
32: * @author gkanos
33: ****************************************/
34: public class StatementFinder extends QuestionAnswerAdaptor<Integer, PStm>
35: {
36:         protected static IInterpreterAssistantFactory af;
37:
38:         @SuppressWarnings("static-access")
39:         public StatementFinder(IInterpreterAssistantFactory af)
40:         {
41:                 this.af = af;
42:         }
43:
44:         @Override
45:         public PStm caseAAlwaysStm(AAlwaysStm stm, Integer lineno)
46:                         throws AnalysisException
47:         {
48:                 PStm found = findStatementBaseCase(stm, lineno);
49:•                if (found != null)
50:                 {
51:                         return found;
52:                 }
53:                 found = stm.getAlways().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stm.getAlways(), lineno);
54:•                if (found != null)
55:                 {
56:                         return found;
57:                 }
58:                 return stm.getBody().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stm.getBody(), lineno);
59:         }
60:
61:         @Override
62:         public PStm caseAAtomicStm(AAtomicStm stm, Integer lineno)
63:                         throws AnalysisException
64:         {
65:                 PStm found = findStatementBaseCase(stm, lineno);
66:•                if (found != null)
67:                 {
68:                         return found;
69:                 }
70:
71:•                for (AAssignmentStm stmt : stm.getAssignments())
72:                 {
73:                         found = stmt.apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stmt, lineno);
74:•                        if (found != null)
75:                         {
76:                                 break;
77:                         }
78:                 }
79:
80:                 return found;
81:         }
82:
83:         @Override
84:         public PStm caseACasesStm(ACasesStm stm, Integer lineno)
85:                         throws AnalysisException
86:         {
87:                 PStm found = findStatementBaseCase(stm, lineno);
88:•                if (found != null)
89:                 {
90:                         return found;
91:                 }
92:
93:•                for (ACaseAlternativeStm stmt : stm.getCases())
94:                 {
95:                         found = stmt.getResult().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stmt.getResult(),
96:                                                                                                                         // lineno);
97:•                        if (found != null)
98:                         {
99:                                 break;
100:                         }
101:                 }
102:
103:                 return found;
104:         }
105:
106:         @Override
107:         public PStm caseACyclesStm(ACyclesStm stm, Integer lineno)
108:                         throws AnalysisException
109:         {
110:                 return stm.getStatement().apply(THIS, lineno);
111:         }
112:
113:         @Override
114:         public PStm caseADurationStm(ADurationStm stm, Integer lineno)
115:                         throws AnalysisException
116:         {
117:                 return stm.getStatement().apply(THIS, lineno);
118:         }
119:
120:         @Override
121:         public PStm caseAElseIfStm(AElseIfStm stm, Integer lineno)
122:                         throws AnalysisException
123:         {
124:                 PStm found = findStatementBaseCase(stm, lineno);
125:•                if (found != null)
126:                 {
127:                         return found;
128:                 }
129:                 return stm.getThenStm().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stm.getThenStm(), lineno);
130:         }
131:
132:         @Override
133:         public PStm caseAForAllStm(AForAllStm stm, Integer lineno)
134:                         throws AnalysisException
135:         {
136:                 PStm found = findStatementBaseCase(stm, lineno);
137:•                if (found != null)
138:                 {
139:                         return found;
140:                 }
141:                 return stm.getStatement().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stm.getStatement(),
142:                                                                                                                 // lineno);
143:         }
144:
145:         @Override
146:         public PStm caseAForIndexStm(AForIndexStm stm, Integer lineno)
147:                         throws AnalysisException
148:         {
149:                 PStm found = findStatementBaseCase(stm, lineno);
150:•                if (found != null)
151:                 {
152:                         return found;
153:                 }
154:                 return stm.getStatement().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stm.getStatement(),
155:                                                                                                                 // lineno);
156:         }
157:
158:         @Override
159:         public PStm caseAForPatternBindStm(AForPatternBindStm stm, Integer lineno)
160:                         throws AnalysisException
161:         {
162:                 PStm found = findStatementBaseCase(stm, lineno);
163:•                if (found != null)
164:                 {
165:                         return found;
166:                 }
167:                 return stm.getStatement().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stm.getStatement(),
168:                                                                                                                 // lineno);
169:         }
170:
171:         @Override
172:         public PStm caseAIfStm(AIfStm stm, Integer lineno) throws AnalysisException
173:         {
174:                 PStm found = findStatementBaseCase(stm, lineno);
175:•                if (found != null)
176:                 {
177:                         return found;
178:                 }
179:                 found = stm.getThenStm().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stm.getThenStm(),
180:                                                                                                                 // lineno);
181:•                if (found != null)
182:                 {
183:                         return found;
184:                 }
185:
186:•                for (AElseIfStm stmt : stm.getElseIf())
187:                 {
188:                         found = stmt.apply(THIS, lineno);// af.createPStmAssistant().findStatement(stmt, lineno);
189:•                        if (found != null)
190:                         {
191:                                 return found;
192:                         }
193:                 }
194:
195:•                if (stm.getElseStm() != null)
196:                 {
197:                         found = stm.getElseStm().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stm.getElseStm(),
198:                                                                                                                         // lineno);
199:                 }
200:
201:                 return found;
202:         }
203:
204:         @Override
205:         public PStm caseALetBeStStm(ALetBeStStm stm, Integer lineno)
206:                         throws AnalysisException
207:         {
208:                 PStm found = findStatementBaseCase(stm, lineno);
209:•                if (found != null)
210:                 {
211:                         return found;
212:                 }
213:                 return stm.getStatement().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stm.getStatement(),
214:                                                                                                                 // lineno);
215:         }
216:
217:         @Override
218:         public PStm caseALetStm(ALetStm stm, Integer lineno)
219:                         throws AnalysisException
220:         {
221:                 PStm found = findStatementBaseCase(stm, lineno);
222:•                if (found != null)
223:                 {
224:                         return found;
225:                 }
226:
227:                 found = af.createPDefinitionAssistant().findStatement(stm.getLocalDefs(), lineno);
228:•                if (found != null)
229:                 {
230:                         return found;
231:                 }
232:
233:                 return stm.getStatement().apply(THIS, lineno); // StmAssistantInterpreter.findStatement(stm.getStatement(),
234:                                                                                                                 // lineno);
235:         }
236:
237:         @Override
238:         public PStm defaultSSimpleBlockStm(SSimpleBlockStm stm, Integer lineno)
239:                         throws AnalysisException
240:         {
241:•                if (stm.getLocation().getStartLine() == lineno)
242:                 {
243:                         return stm;
244:                 }
245:                 PStm found = null;
246:
247:•                for (PStm stmt : stm.getStatements())
248:                 {
249:                         found = stmt.apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stmt, lineno);
250:•                        if (found != null)
251:                         {
252:                                 break;
253:                         }
254:                 }
255:
256:                 return found;
257:         }
258:
259:         @Override
260:         public PStm caseATixeStm(ATixeStm stm, Integer lineno)
261:                         throws AnalysisException
262:         {
263:                 PStm found = findStatementBaseCase(stm, lineno);
264:•                if (found != null)
265:                 {
266:                         return found;
267:                 }
268:                 found = stm.getBody().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stm.getBody(), lineno);
269:•                if (found != null)
270:                 {
271:                         return found;
272:                 }
273:
274:•                for (ATixeStmtAlternative tsa : stm.getTraps())
275:                 {
276:                         found = tsa.getStatement().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(tsa.getStatement(),
277:                                                                                                                         // lineno);
278:•                        if (found != null)
279:                         {
280:                                 break;
281:                         }
282:                 }
283:
284:                 return found;
285:         }
286:
287:         @Override
288:         public PStm caseATrapStm(ATrapStm stm, Integer lineno)
289:                         throws AnalysisException
290:         {
291:                 PStm found = findStatementBaseCase(stm, lineno);
292:•                if (found != null)
293:                 {
294:                         return found;
295:                 }
296:                 found = stm.getBody().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stm.getBody(), lineno);
297:•                if (found != null)
298:                 {
299:                         return found;
300:                 }
301:                 return stm.getWith().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stm.getWith(), lineno);
302:         }
303:
304:         @Override
305:         public PStm caseAWhileStm(AWhileStm stm, Integer lineno)
306:                         throws AnalysisException
307:         {
308:                 PStm found = findStatementBaseCase(stm, lineno);
309:•                if (found != null)
310:                 {
311:                         return found;
312:                 }
313:                 return stm.getStatement().apply(THIS, lineno); // PStmAssistantInterpreter.findStatement(stm.getStatement(),
314:                                                                                                                 // lineno);
315:         }
316:
317:         @Override
318:         public PStm defaultPStm(PStm stm, Integer lineno) throws AnalysisException
319:         {
320:                 return findStatementBaseCase(stm, lineno);
321:         }
322:
323:         @Override
324:         public PStm caseAAnnotatedStm(AAnnotatedStm node, Integer question)        throws AnalysisException
325:         {
326:                 return node.getStmt().apply(THIS, question);
327:         }
328:         
329:         @Override
330:         public PStm createNewReturnValue(INode node, Integer question)
331:                         throws AnalysisException
332:         {
333:                 // TODO Auto-generated method stub
334:                 return null;
335:         }
336:
337:         @Override
338:         public PStm createNewReturnValue(Object node, Integer question)
339:                         throws AnalysisException
340:         {
341:                 // TODO Auto-generated method stub
342:                 return null;
343:         }
344:
345:         public static PStm findStatementBaseCase(PStm stm, int lineno)
346:         {
347:•                return stm.getLocation().getStartLine() == lineno ? stm : null;
348:         }
349: }