source: branches/t3e-tools/t3q/src/org/etsi/t3q/visitor/T3QVisitor.java @ 28

Last change on this file since 28 was 28, checked in by phdmakk, 14 years ago
  • Property svn:mime-type set to text/plain
File size: 15.7 KB
Line 
1package org.etsi.t3q.visitor;
2
3import java.util.LinkedList;
4
5import org.etsi.t3q.T3Q;
6import org.etsi.t3q.exceptions.TTCN3BehaviorException;
7
8import de.ugoe.cs.swe.trex.core.analyzer.rfparser.LocationAST;
9
10public class T3QVisitor extends AbstractVisitor {
11
12        private LinkedList<LocationAST> functionStatementOrDefNodes = new LinkedList<LocationAST>();
13        private QualityChecker checker = new QualityChecker(this);
14        private NamingConventionsChecker namingConventionsChecker = new NamingConventionsChecker(
15                        checker);
16
17        private String filename;
18       
19        @Override
20        public void finish() {
21        }
22
23        @Override
24        public void init() {
25                //TODO: Document feature
26                checker.getLoggingInterface().setLogSourceName(this.getFilename());
27                checker.stringLevelChecks(this.getFilename());
28        }
29       
30
31        //TODO: temporary addition?
32        public ContinueStatus visitModeSpecification(LocationAST node)
33                        throws TTCN3BehaviorException {
34                if (T3Q.activeProfile.getEmbeddedExtensionConfig()
35                                                                .isCheckNoNestedModes()) {
36                        checker.checkNoNestedModes(node);
37                }
38                return ContinueStatus.getInstance(true, true);
39        }
40       
41       
42        //TODO: temporary addition?
43        public ContinueStatus visitWaitStatement(LocationAST node)
44                        throws TTCN3BehaviorException {
45                if (T3Q.activeProfile.getRealtimeExtensionConfig().isCheckWaitStatementPrecededByLog()) {
46                        checker.checkWaitStatementPrecededByLog(node);
47                }
48                return ContinueStatus.getInstance(true, true);
49        }
50       
51       
52        public ContinueStatus visitIdentifier(LocationAST node)
53                        throws TTCN3BehaviorException {
54                return ContinueStatus.getInstance(true, true);
55        }
56
57        public ContinueStatus visitTTCN3Module(LocationAST node)
58                        throws TTCN3BehaviorException {
59                if (T3Q.activeProfile.isCheckModuleSize()) {
60                        checker.checkModuleSize(node);
61                }
62//              String output = "";
63//              System.out.println(LocationAST.dumpTree(node,1,output));
64                return ContinueStatus.getInstance(true, true);
65        }
66
67        public ContinueStatus visitModuleDefinition(LocationAST node)
68                        throws TTCN3BehaviorException {
69                if (T3Q.activeProfile.isCheckNoDuplicatedModuleDefinitionIdentifiers()) {
70                        checker.checkNoDuplicatedModuleDefinitionIdentifiers(node);
71                }
72                if (T3Q.activeProfile.isCheckZeroReferencedModuleDefinitions()) {
73                        checker.checkZeroReferencedModuleDefinitions(node);
74                }
75                if (T3Q.activeProfile.isCheckLocalDefinitionsComeFirst()) {
76                        checker.checkLocalDefinitionsComeFirst(node);
77                }
78                if (T3Q.activeProfile.isCheckNoUnusedLocalDefinitions()) {
79                        checker.checkNoUnusedLocalDefinitions(node);
80                }
81
82                return ContinueStatus.getInstance(true, true);
83        }
84
85        public ContinueStatus visitSingleConstDef(LocationAST node)
86                        throws TTCN3BehaviorException {
87                if (T3Q.activeProfile.isCheckNamingConventions()) {
88                        namingConventionsChecker.checkConstant(node);
89                }
90
91                return ContinueStatus.getInstance(true, true);
92        }
93
94        public ContinueStatus visitExtConstDef(LocationAST node)
95                        throws TTCN3BehaviorException {
96                if (T3Q.activeProfile.isCheckNamingConventions()) {
97                        namingConventionsChecker.checkExtConstant(node);
98                }
99
100                return ContinueStatus.getInstance(true, true);
101        }
102
103        public ContinueStatus visitGroupDef(LocationAST node)
104                        throws TTCN3BehaviorException {
105                if (T3Q.activeProfile.isCheckTypeDefOrderInGroup()) {
106                        checker.checkTypeDefOrderInGroup(node);
107                }
108                if (T3Q.activeProfile.isCheckNamingConventions()) {
109                        namingConventionsChecker.checkGroup(node);
110                }
111                return ContinueStatus.getInstance(true, true);
112        }
113
114        public ContinueStatus visitPortDef(LocationAST node)
115                        throws TTCN3BehaviorException {
116                if (T3Q.activeProfile.isCheckNoAllKeywordInPortDefinitions()) {
117                        checker.checkNoAllKeywordInPortDefinitions(node);
118                }
119
120                if (T3Q.activeProfile.isCheckPortMessageGrouping()) {
121                        checker.checkPortMessageGrouping(node);
122                }
123
124                return ContinueStatus.getInstance(true, true);
125        }
126
127        public ContinueStatus visitPortInstance(LocationAST node)
128                        throws TTCN3BehaviorException {
129                if (T3Q.activeProfile.isCheckNamingConventions()) {
130                        namingConventionsChecker.checkPortInstance(node);
131                }
132
133                return ContinueStatus.getInstance(true, true);
134        }
135
136        public ContinueStatus visitModuleParList(LocationAST node)
137                        throws TTCN3BehaviorException {
138                if (T3Q.activeProfile.isCheckNamingConventions()) {
139                        namingConventionsChecker.checkModuleParameter(node);
140                }
141                return ContinueStatus.getInstance(true, true);
142        }
143
144        public ContinueStatus visitTTCN3ModuleId(LocationAST node) {
145                if (T3Q.activeProfile.isFeatureListImportingModuleNames()) {
146                        checker.listImportingModuleNames(node);
147                }
148                if (T3Q.activeProfile.isFeatureListImportingModuleFileNames()) {
149                        checker.listImportingModuleFileNames(node);
150                }
151       
152                if (T3Q.activeProfile.isCheckImportsComeFirst()) {
153                        checker.checkImportsComeFirst(node);
154                }
155
156                if (T3Q.activeProfile
157                                .isCheckTypesAndValuesModuleImportsLibNames()) {
158                        checker.checkTypesAndValuesModuleImportsLibCommon(node);
159                }
160
161                if (T3Q.activeProfile
162                                .isCheckTestcasesModuleImportsLibCommon_Sync()) {
163                        checker.checkTestcasesModuleImportsLibCommon_Sync(node);
164                }
165
166                if (T3Q.activeProfile
167                                .isCheckTypesAndValuesModuleContainmentCheck()) {
168                        checker.checkModuleContainment(node, "TypesAndValues");
169                }
170                if (T3Q.activeProfile.isCheckTemplatesModuleContainmentCheck()) {
171                        checker.checkModuleContainment(node, "Templates");
172                }
173                if (T3Q.activeProfile.isCheckFunctionsModuleContainmentCheck()) {
174                        checker.checkModuleContainment(node, "Functions");
175                }
176                if (T3Q.activeProfile.isCheckTestcasesModuleContainmentCheck()) {
177                        checker.checkModuleContainment(node, "Testcases");
178                }
179                if (T3Q.activeProfile.isCheckModuleParamsModuleContainmentCheck()) {
180                        checker.checkModuleContainment(node, "ModuleParams");
181                }
182                if (T3Q.activeProfile.isCheckInterfaceModuleContainmentCheck()) {
183                        checker.checkModuleContainment(node, "Interface");
184                }
185                if (T3Q.activeProfile.isCheckTestSystemModuleContainmentCheck()) {
186                        checker.checkModuleContainment(node, "TestSystem");
187                }
188                if (T3Q.activeProfile.isCheckTestControlModuleContainmentCheck()) {
189                        checker.checkModuleContainment(node, "TestControl");
190                }
191                if (T3Q.activeProfile.isCheckNamingConventions()) {
192                        namingConventionsChecker.checkModule(node);
193                }
194                return ContinueStatus.getInstance(true, true);
195        }
196
197        public ContinueStatus visitAltConstruct(LocationAST node)
198                        throws TTCN3BehaviorException {
199
200                if (T3Q.activeProfile.isCheckNoNestedAltStatements()) {
201                        checker.checkNoNestedAltStatements(node);
202                }
203
204                return ContinueStatus.getInstance(true, true);
205        }
206
207        public ContinueStatus visitRunsOnSpec(LocationAST node)
208                        throws TTCN3BehaviorException {
209                if (T3Q.activeProfile.isCheckNoOverSpecificRunsOnClauses()) {
210                        checker.checkNoOverSpecificRunsOnClauses(node);
211                }
212
213                return ContinueStatus.getInstance(true, true);
214        }
215
216        public ContinueStatus visitImportDef(LocationAST node)
217                        throws TTCN3BehaviorException {
218
219                if (T3Q.activeProfile.isFeatureListImportedModuleNames()) {
220                        checker.listImportedModuleNames(node);
221                }
222                if (T3Q.activeProfile.isFeatureListImportedModuleFileNames()) {
223                        checker.listImportedModuleFileNames(node);
224                }
225
226                if (T3Q.activeProfile.isCheckNoUnusedImports()) {
227                        checker.checkNoUnusedImports(node);
228                }
229
230                return ContinueStatus.getInstance(true, true);
231        }
232
233       
234        public ContinueStatus visitAnyTypeKeyword(LocationAST node)
235                        throws TTCN3BehaviorException {
236
237                if (T3Q.activeProfile.isCheckNoAnyTypeKeyword()) {
238                        checker.checkNoAnyTypeKeyword(node);
239                }
240
241                return ContinueStatus.getInstance(true, true);
242        }
243
244        public ContinueStatus visitVarInstance(LocationAST node)
245                        throws TTCN3BehaviorException {
246                if (T3Q.activeProfile.isCheckNamingConventions()) {
247                        namingConventionsChecker.checkVariable(node);
248                }
249
250                return ContinueStatus.getInstance(true, true);
251        }
252
253        public ContinueStatus visitTimerInstance(LocationAST node)
254                        throws TTCN3BehaviorException {
255                if (T3Q.activeProfile.isCheckNamingConventions()) {
256                        namingConventionsChecker.checkTimer(node);
257                }
258
259                return ContinueStatus.getInstance(true, true);
260        }
261
262        public ContinueStatus visitInLineTemplate(LocationAST node)
263                        throws TTCN3BehaviorException {
264                if (T3Q.activeProfile.isCheckNoInlineTemplates()) {
265                        checker.checkNoInlineTemplates(node);
266                }
267
268                return ContinueStatus.getInstance(true, true);
269        }
270
271        public ContinueStatus visitTemplateDef(LocationAST node)
272                        throws TTCN3BehaviorException {
273                if (T3Q.activeProfile.isCheckNamingConventions()) {
274                        namingConventionsChecker.checkMessageTemplate(node);
275                }
276                if (T3Q.activeProfile.isCheckNamingConventions()) {
277                        namingConventionsChecker.checkSTF160Template(node);
278                }
279
280                return ContinueStatus.getInstance(true, true);
281        }
282
283        public ContinueStatus visitDerivedDef(LocationAST node)
284                        throws TTCN3BehaviorException {
285
286                if (T3Q.activeProfile
287                                .isCheckNoModifiedTemplateOfModifiedTemplate()) {
288
289                        checker.checkNoModifiedTemplateOfModifiedTemplate(node);
290                }
291
292                return ContinueStatus.getInstance(true, true);
293        }
294
295        public ContinueStatus visitExtFunctionDef(LocationAST node)
296                        throws TTCN3BehaviorException {
297                if (T3Q.activeProfile.isCheckNamingConventions()) {
298                        namingConventionsChecker.checkExtFunction(node);
299                }
300
301                return ContinueStatus.getInstance(true, true);
302        }
303
304        public ContinueStatus visitSignatureDef(LocationAST node)
305                        throws TTCN3BehaviorException {
306                if (T3Q.activeProfile.isCheckNamingConventions()) {
307                        namingConventionsChecker.checkSignatureTemplate(node);
308                }
309
310                return ContinueStatus.getInstance(true, true);
311        }
312
313        public ContinueStatus visitFormalValuePar(LocationAST node)
314                        throws TTCN3BehaviorException {
315                if (T3Q.activeProfile.isCheckNamingConventions()) {
316                        namingConventionsChecker.checkFormalParameter(node);
317                }
318                if (T3Q.activeProfile.isCheckNoUnusedFormalParameters()) {
319                        checker.checkNoUnusedFormalParameters(node);
320                }
321
322                return ContinueStatus.getInstance(true, true);
323        }
324
325        public ContinueStatus visitFormalTemplatePar(LocationAST node)
326                        throws TTCN3BehaviorException {
327                if (T3Q.activeProfile.isCheckNamingConventions()) {
328                        namingConventionsChecker.checkFormalParameter(node);
329                }
330                if (T3Q.activeProfile.isCheckNoUnusedFormalParameters()) {
331                        checker.checkNoUnusedFormalParameters(node);
332                }
333
334                return ContinueStatus.getInstance(true, true);
335        }
336
337        public ContinueStatus visitFormalTimerPar(LocationAST node)
338                        throws TTCN3BehaviorException {
339                if (T3Q.activeProfile.isCheckNamingConventions()) {
340                        namingConventionsChecker.checkFormalParameter(node);
341                }
342                if (T3Q.activeProfile.isCheckNoUnusedFormalParameters()) {
343                        checker.checkNoUnusedFormalParameters(node);
344                }
345
346                return ContinueStatus.getInstance(true, true);
347        }
348
349        public ContinueStatus visitFormalPortPar(LocationAST node)
350                        throws TTCN3BehaviorException {
351                if (T3Q.activeProfile.isCheckNoUnusedFormalParameters()) {
352                        checker.checkNoUnusedFormalParameters(node);
353                }
354                return ContinueStatus.getInstance(true, true);
355        }
356
357        public ContinueStatus visitPredefinedValue(LocationAST node)
358                        throws TTCN3BehaviorException {
359                if (T3Q.activeProfile.isCheckNoLiterals()) {
360                        checker.checkNoLiterals(node);
361                }
362                return ContinueStatus.getInstance(true, true);
363        }
364       
365
366        public ContinueStatus visitTypeDef(LocationAST node)
367                        throws TTCN3BehaviorException {
368                if (T3Q.activeProfile.isCheckNamingConventions()) {
369                        namingConventionsChecker.checkDataType(node);
370                }
371
372                return ContinueStatus.getInstance(true, true);
373        }
374
375        public ContinueStatus visitEnumeration(LocationAST node)
376                        throws TTCN3BehaviorException {
377                if (T3Q.activeProfile.isCheckNamingConventions()) {
378                        namingConventionsChecker.checkEnumeratedValue(node);
379                }
380
381                return ContinueStatus.getInstance(true, true);
382        }
383       
384        public ContinueStatus visitStatementBlock(LocationAST node)
385                        throws TTCN3BehaviorException {
386                functionStatementOrDefNodes.clear();
387                return ContinueStatus.getInstance(true, true);
388        }
389
390        public ContinueStatus visitFunctionDef(LocationAST node)
391                        throws TTCN3BehaviorException {
392                functionStatementOrDefNodes.clear();
393                if (T3Q.activeProfile.isCheckNamingConventions()) {
394                        namingConventionsChecker.checkFunction(node);
395                }
396                return ContinueStatus.getInstance(true, true);
397        }
398
399        public ContinueStatus visitTestcaseDef(LocationAST node)
400                        throws TTCN3BehaviorException {
401                functionStatementOrDefNodes.clear();
402                if (T3Q.activeProfile.isCheckNamingConventions()) {
403                        namingConventionsChecker.checkTestcase(node);
404                }
405                return ContinueStatus.getInstance(true, true);
406        }
407
408        public ContinueStatus visitAltstepDef(LocationAST node)
409                        throws TTCN3BehaviorException {
410                functionStatementOrDefNodes.clear();
411                if (T3Q.activeProfile.isCheckNamingConventions()) {
412                        namingConventionsChecker.checkAltstep(node);
413                }
414                return ContinueStatus.getInstance(true, true);
415        }
416
417        public ContinueStatus visitModuleControlPart(LocationAST node)
418                        throws TTCN3BehaviorException {
419                functionStatementOrDefNodes.clear();
420
421                return ContinueStatus.getInstance(true, true);
422        }
423
424        public ContinueStatus visitModuleControlBody(LocationAST node)
425                        throws TTCN3BehaviorException {
426
427                if (T3Q.activeProfile.isCheckLocalDefinitionsComeFirst()) {
428                        checker.checkLocalDefinitionsComeFirstWithinControlPart(node);
429                }
430                if (T3Q.activeProfile.isCheckNoUnusedLocalDefinitions()) {
431                        checker.checkNoUnusedLocalDefinitions(node);
432                }
433
434                return ContinueStatus.getInstance(true, true);
435        }
436       
437       
438       
439        public ContinueStatus visitFunctionRef(LocationAST node)
440                        throws TTCN3BehaviorException {
441
442                if (T3Q.activeProfile
443                                .isCheckExternalFunctionInvocationPrecededByLogStatement()) {
444
445                        checker.checkExternalFunctionInvocationPrecededByLogStatement(node);
446                }
447
448                return ContinueStatus.getInstance(true, true);
449        }
450
451        public ContinueStatus visitGotoStatement(LocationAST node)
452                        throws TTCN3BehaviorException {
453
454                if (T3Q.activeProfile.isCheckNoLabelsOrGotoStatements()) {
455                        checker.checkNoGotoStatements(node);
456                }
457
458                return ContinueStatus.getInstance(true, true);
459        }
460
461        public ContinueStatus visitLabelStatement(LocationAST node)
462                        throws TTCN3BehaviorException {
463
464                if (T3Q.activeProfile.isCheckNoLabelsOrGotoStatements()) {
465                        checker.checkNoLabelStatements(node);
466                }
467
468                return ContinueStatus.getInstance(true, true);
469        }
470
471        public ContinueStatus visitLogItem(LocationAST node)
472                        throws TTCN3BehaviorException {
473
474                if (T3Q.activeProfile.isCheckLogItemFormat()) {
475                        checker.checkLogItemFormat(node);
476                }
477                return ContinueStatus.getInstance(true, true);
478        }
479       
480        public ContinueStatus visitLogStatement(LocationAST node)
481                        throws TTCN3BehaviorException {
482                //TODO: Temporary/TEMEA+Enhancements
483                //may also be adopted instead of log item checking
484                if (T3Q.activeProfile.isCheckLogStatementFormat()) {
485                        checker.checkLogStatementFormat(node);
486                }
487                return ContinueStatus.getInstance(true, true);
488        }
489
490        public ContinueStatus visitPermutationMatch(LocationAST node)
491                        throws TTCN3BehaviorException {
492
493                if (T3Q.activeProfile.isCheckNoPermutationKeyword()) {
494                        checker.checkNoPermutationKeyword(node);
495                }
496
497                return ContinueStatus.getInstance(true, true);
498        }
499
500        public ContinueStatus visitSetLocalVerdict(LocationAST node)
501                        throws TTCN3BehaviorException {
502
503                if (T3Q.activeProfile
504                                .isCheckInconcOrFailSetVerdictPrecededByLog()) {
505                        checker.checkInconcOrFailSetVerdictPrecededByLog(node);
506                }
507
508                return ContinueStatus.getInstance(true, true);
509        }
510
511        public ContinueStatus visitFunctionStatementOrDef(LocationAST node)
512                        throws TTCN3BehaviorException {
513                //TODO: deprecated
514                functionStatementOrDefNodes.add(node);
515                return ContinueStatus.getInstance(true, true);
516        }
517
518        public ContinueStatus visitFunctionStatement(LocationAST node)
519                        throws TTCN3BehaviorException {
520
521                functionStatementOrDefNodes.add(node);
522                return ContinueStatus.getInstance(true, true);
523        }       
524       
525        public ContinueStatus visitFunctionLocalInst(LocationAST node)
526                        throws TTCN3BehaviorException {
527
528                functionStatementOrDefNodes.add(node);
529                return ContinueStatus.getInstance(true, true);
530        }       
531
532        public ContinueStatus visitFunctionLocalDef(LocationAST node)
533                        throws TTCN3BehaviorException {
534
535                functionStatementOrDefNodes.add(node);
536                return ContinueStatus.getInstance(true, true);
537        }
538       
539       
540        public LinkedList<LocationAST> getFunctionStatementOrDefNodes() {
541                return functionStatementOrDefNodes;
542        }
543
544        public void setFilename(String filename) {
545                this.filename = filename;
546        }
547
548        public String getFilename() {
549                return filename;
550        }
551
552
553
554}
Note: See TracBrowser for help on using the repository browser.