Package: TypeDefinitionChecker

TypeDefinitionChecker

nameinstructionbranchcomplexitylinemethod
TypeDefinitionChecker(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%
caseAClassClassDefinition(AClassClassDefinition)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
caseAImportedDefinition(AImportedDefinition)
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%
caseAInheritedDefinition(AInheritedDefinition)
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%
caseARenamedDefinition(ARenamedDefinition)
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%
caseATypeDefinition(ATypeDefinition)
M: 0 C: 3
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%
defaultPDefinition(PDefinition)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
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: package org.overture.typechecker.utilities;
2:
3: import org.overture.ast.analysis.AnalysisException;
4: import org.overture.ast.analysis.AnswerAdaptor;
5: import org.overture.ast.definitions.AClassClassDefinition;
6: import org.overture.ast.definitions.AImportedDefinition;
7: import org.overture.ast.definitions.AInheritedDefinition;
8: import org.overture.ast.definitions.ARenamedDefinition;
9: import org.overture.ast.definitions.ATypeDefinition;
10: import org.overture.ast.definitions.PDefinition;
11: import org.overture.ast.node.INode;
12: import org.overture.typechecker.assistant.ITypeCheckerAssistantFactory;
13:
14: /**
15: * This class implements a way to check if a node is a type definition.
16: */
17:•public class TypeDefinitionChecker extends AnswerAdaptor<Boolean>
18: {
19:         protected ITypeCheckerAssistantFactory af;
20:
21:         public TypeDefinitionChecker(ITypeCheckerAssistantFactory af)
22:         {
23:                 this.af = af;
24:         }
25:
26:         @Override
27:         public Boolean caseATypeDefinition(ATypeDefinition node) throws AnalysisException
28:         {
29:                 return true;
30:         };
31:         
32:         @Override
33:         public Boolean caseAClassClassDefinition(AClassClassDefinition node) throws AnalysisException
34:         {
35:                 return true;        // Class is regarded as a type
36:         }
37:         
38:         @Override
39:         public Boolean caseAImportedDefinition(AImportedDefinition node) throws AnalysisException
40:         {
41:                 return node.getDef().apply(this);
42:         }
43:         
44:         public Boolean caseAInheritedDefinition(AInheritedDefinition node) throws AnalysisException
45:         {
46:                 return node.getSuperdef().apply(this);
47:         };
48:
49:         @Override
50:         public Boolean caseARenamedDefinition(ARenamedDefinition node)
51:                 throws AnalysisException
52:         {
53:                 return node.getDef().apply(this);
54:         }
55:         
56:         @Override
57:         public Boolean defaultPDefinition(PDefinition node)
58:                         throws AnalysisException
59:         {
60:                 return false;
61:         }
62:
63:         @Override
64:         public Boolean createNewReturnValue(INode node)
65:         {
66:•                assert false : "should not happen";
67:                 return null;
68:         }
69:
70:         @Override
71:         public Boolean createNewReturnValue(Object node)
72:         {
73:•                assert false : "should not happen";
74:                 return null;
75:         }
76: }