Package: VariableNameCollector

VariableNameCollector

nameinstructionbranchcomplexitylinemethod
VariableNameCollector(ITypeCheckerAssistantFactory)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAAssignmentDefinition(AAssignmentDefinition)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAClassInvariantDefinition(AClassInvariantDefinition)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAEqualsDefinition(AEqualsDefinition)
M: 4 C: 10
71%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 2
100%
M: 0 C: 1
100%
caseAExplicitFunctionDefinition(AExplicitFunctionDefinition)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAExplicitOperationDefinition(AExplicitOperationDefinition)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAExternalDefinition(AExternalDefinition)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAImplicitFunctionDefinition(AImplicitFunctionDefinition)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAImplicitOperationDefinition(AImplicitOperationDefinition)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAImportedDefinition(AImportedDefinition)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAInheritedDefinition(AInheritedDefinition)
M: 0 C: 32
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
caseAInstanceVariableDefinition(AInstanceVariableDefinition)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseALocalDefinition(ALocalDefinition)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAMultiBindListDefinition(AMultiBindListDefinition)
M: 4 C: 10
71%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 2
100%
M: 0 C: 1
100%
caseAMutexSyncDefinition(AMutexSyncDefinition)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseANamedTraceDefinition(ANamedTraceDefinition)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAPerSyncDefinition(APerSyncDefinition)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseARenamedDefinition(ARenamedDefinition)
M: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAStateDefinition(AStateDefinition)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAThreadDefinition(AThreadDefinition)
M: 2 C: 10
83%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 2
100%
M: 0 C: 1
100%
caseATypeDefinition(ATypeDefinition)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAUntypedDefinition(AUntypedDefinition)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
caseAValueDefinition(AValueDefinition)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
createNewReturnValue(INode)
M: 9 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
createNewReturnValue(Object)
M: 9 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
defaultSClassDefinition(SClassDefinition)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 2 C: 6
75%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * #%~
3: * The VDM Type Checker
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.typechecker.utilities;
23:
24: import org.overture.ast.analysis.AnalysisException;
25: import org.overture.ast.analysis.AnswerAdaptor;
26: import org.overture.ast.definitions.AAssignmentDefinition;
27: import org.overture.ast.definitions.AClassInvariantDefinition;
28: import org.overture.ast.definitions.AEqualsDefinition;
29: import org.overture.ast.definitions.AExplicitFunctionDefinition;
30: import org.overture.ast.definitions.AExplicitOperationDefinition;
31: import org.overture.ast.definitions.AExternalDefinition;
32: import org.overture.ast.definitions.AImplicitFunctionDefinition;
33: import org.overture.ast.definitions.AImplicitOperationDefinition;
34: import org.overture.ast.definitions.AImportedDefinition;
35: import org.overture.ast.definitions.AInheritedDefinition;
36: import org.overture.ast.definitions.AInstanceVariableDefinition;
37: import org.overture.ast.definitions.ALocalDefinition;
38: import org.overture.ast.definitions.AMultiBindListDefinition;
39: import org.overture.ast.definitions.AMutexSyncDefinition;
40: import org.overture.ast.definitions.ANamedTraceDefinition;
41: import org.overture.ast.definitions.APerSyncDefinition;
42: import org.overture.ast.definitions.ARenamedDefinition;
43: import org.overture.ast.definitions.AStateDefinition;
44: import org.overture.ast.definitions.AThreadDefinition;
45: import org.overture.ast.definitions.ATypeDefinition;
46: import org.overture.ast.definitions.AUntypedDefinition;
47: import org.overture.ast.definitions.AValueDefinition;
48: import org.overture.ast.definitions.SClassDefinition;
49: import org.overture.ast.intf.lex.ILexNameToken;
50: import org.overture.ast.lex.LexNameList;
51: import org.overture.ast.node.INode;
52: import org.overture.typechecker.assistant.ITypeCheckerAssistantFactory;
53:
54: //TODO Add assistant Javadoc
55:
56: /**
57: * A refactored assistant / functionality visitor. This class implements a way to collect variable names from any node
58: * in the AST
59: *
60: * @author kel
61: */
62:•public class VariableNameCollector extends AnswerAdaptor<LexNameList>
63: {
64:
65:         protected ITypeCheckerAssistantFactory af;
66:
67:         public VariableNameCollector(ITypeCheckerAssistantFactory af)
68:         {
69:                 this.af = af;
70:         }
71:
72:         @Override
73:         public LexNameList caseAAssignmentDefinition(AAssignmentDefinition node)
74:                         throws AnalysisException
75:         {
76:                 return new LexNameList(node.getName());
77:         }
78:
79:         @Override
80:         public LexNameList defaultSClassDefinition(SClassDefinition node)
81:                         throws AnalysisException
82:         {
83:                 return af.createPDefinitionListAssistant().getVariableNames(node.getDefinitions());
84:         }
85:
86:         @Override
87:         public LexNameList caseAClassInvariantDefinition(
88:                         AClassInvariantDefinition node) throws AnalysisException
89:         {
90:                 return new LexNameList(node.getName());
91:         }
92:
93:         @Override
94:         public LexNameList caseAEqualsDefinition(AEqualsDefinition node)
95:                         throws AnalysisException
96:         {
97:•                return node.getDefs() == null ? new LexNameList()
98:                                 : af.createPDefinitionListAssistant().getVariableNames(node.getDefs());
99:         }
100:
101:         @Override
102:         public LexNameList caseAExplicitFunctionDefinition(
103:                         AExplicitFunctionDefinition node) throws AnalysisException
104:         {
105:                 return new LexNameList(node.getName());
106:         }
107:
108:         @Override
109:         public LexNameList caseAExplicitOperationDefinition(
110:                         AExplicitOperationDefinition node) throws AnalysisException
111:         {
112:                 return new LexNameList(node.getName());
113:         }
114:
115:         @Override
116:         public LexNameList caseAExternalDefinition(AExternalDefinition node)
117:                         throws AnalysisException
118:         {
119:                 return node.getState().apply(THIS); // TODO: Is this applicable?
120:         }
121:
122:         @Override
123:         public LexNameList caseAImplicitFunctionDefinition(
124:                         AImplicitFunctionDefinition node) throws AnalysisException
125:         {
126:                 return new LexNameList(node.getName());
127:         }
128:
129:         @Override
130:         public LexNameList caseAImplicitOperationDefinition(
131:                         AImplicitOperationDefinition node) throws AnalysisException
132:         {
133:                 return new LexNameList(node.getName());
134:         }
135:
136:         @Override
137:         public LexNameList caseAImportedDefinition(AImportedDefinition node)
138:                         throws AnalysisException
139:         {
140:                 return node.getDef().apply(THIS);
141:         }
142:
143:         @Override
144:         public LexNameList caseAInheritedDefinition(AInheritedDefinition node)
145:                         throws AnalysisException
146:         {
147:                 // return AInheritedDefinitionAssistantTC.getVariableNames((AInheritedDefinition) node);
148:                 LexNameList names = new LexNameList();
149:                 // TODO:What About Here, how to I need to handle it. like I have it or Bring the method to this class?
150:                 DefinitionTypeFinder.checkSuperDefinition(node);
151:
152:•                for (ILexNameToken vn : node.getSuperdef().apply(THIS))
153:                 {
154:                         names.add(vn.getModifiedName(node.getName().getModule()));
155:                 }
156:
157:                 return names;
158:         }
159:
160:         @Override
161:         public LexNameList caseAInstanceVariableDefinition(
162:                         AInstanceVariableDefinition node) throws AnalysisException
163:         {
164:                 return new LexNameList(node.getName());
165:         }
166:
167:         @Override
168:         public LexNameList caseALocalDefinition(ALocalDefinition node)
169:                         throws AnalysisException
170:         {
171:                 return new LexNameList(node.getName());
172:         }
173:
174:         @Override
175:         public LexNameList caseAMultiBindListDefinition(
176:                         AMultiBindListDefinition node) throws AnalysisException
177:         {
178:•                return node.getDefs() == null ? new LexNameList()
179:                                 : af.createPDefinitionListAssistant().getVariableNames(node.getDefs());
180:         }
181:
182:         @Override
183:         public LexNameList caseAMutexSyncDefinition(AMutexSyncDefinition node)
184:                         throws AnalysisException
185:         {
186:                 return new LexNameList();
187:         }
188:
189:         @Override
190:         public LexNameList caseANamedTraceDefinition(ANamedTraceDefinition node)
191:                         throws AnalysisException
192:         {
193:                 return new LexNameList(node.getName());
194:         }
195:
196:         @Override
197:         public LexNameList caseAPerSyncDefinition(APerSyncDefinition node)
198:                         throws AnalysisException
199:         {
200:                 return new LexNameList();
201:         }
202:
203:         @Override
204:         public LexNameList caseARenamedDefinition(ARenamedDefinition node)
205:                         throws AnalysisException
206:         {
207:                 LexNameList both = new LexNameList(node.getName());
208:                 both.add(node.getDef().getName());
209:                 return both;
210:         }
211:
212:         @Override
213:         public LexNameList caseAStateDefinition(AStateDefinition node)
214:                         throws AnalysisException
215:         {
216:                 return af.createPDefinitionListAssistant().getVariableNames(node.getStateDefs());
217:         }
218:
219:         @Override
220:         public LexNameList caseAThreadDefinition(AThreadDefinition node)
221:                         throws AnalysisException
222:         {
223:•                return node.getOperationDef() == null ? null
224:                                 : new LexNameList(node.getOperationDef().getName());
225:         }
226:
227:         @Override
228:         public LexNameList caseATypeDefinition(ATypeDefinition node)
229:                         throws AnalysisException
230:         {
231:                 return new LexNameList(node.getName());
232:         }
233:
234:         @Override
235:         public LexNameList caseAUntypedDefinition(AUntypedDefinition node)
236:                         throws AnalysisException
237:         {
238:                 return new LexNameList(node.getName());
239:         }
240:
241:         @Override
242:         public LexNameList caseAValueDefinition(AValueDefinition node)
243:                         throws AnalysisException
244:         {
245:                 return af.createPPatternAssistant(node.getLocation().getModule()).getVariableNames(node.getPattern());
246:         }
247:
248:         @Override
249:         public LexNameList createNewReturnValue(INode node)
250:         {
251:•                assert false : "default case should never happen in getVariableNames";
252:                 return null;
253:         }
254:
255:         @Override
256:         public LexNameList createNewReturnValue(Object node)
257:         {
258:•                assert false : "default case should never happen in getVariableNames";
259:                 return null;
260:         }
261:
262: }