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

Last change on this file since 16 was 16, checked in by phdmakk, 14 years ago

+ rt guideline prototype implementation

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