source: trunk/t3q/src/org/etsi/t3q/visitor/T3QVisitor.java @ 7

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