Package: RecClassInfo

RecClassInfo

nameinstructionbranchcomplexitylinemethod
RecClassInfo()
M: 0 C: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
contains(SDeclIR)
M: 0 C: 19
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
inAccessor(INode)
M: 0 C: 13
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
inRec(INode)
M: 2 C: 26
93%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 1 C: 7
88%
M: 0 C: 1
100%
inRecConstructor(INode)
M: 4 C: 15
79%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 2 C: 4
67%
M: 0 C: 1
100%
isRecField(AFieldDeclIR)
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%
register(SDeclIR)
M: 0 C: 10
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 3
100%
M: 0 C: 1
100%
registerRecClass(ADefaultClassDeclIR)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
updateAccessor(AMethodDeclIR, AMethodDeclIR)
M: 0 C: 33
100%
M: 0 C: 6
100%
M: 0 C: 4
100%
M: 0 C: 10
100%
M: 0 C: 1
100%

Coverage

1: package org.overture.codegen.vdm2jml.data;
2:
3: import java.util.HashSet;
4: import java.util.LinkedList;
5: import java.util.List;
6: import java.util.Set;
7:
8: import org.overture.codegen.ir.INode;
9: import org.overture.codegen.ir.SDeclIR;
10: import org.overture.codegen.ir.declarations.ADefaultClassDeclIR;
11: import org.overture.codegen.ir.declarations.AFieldDeclIR;
12: import org.overture.codegen.ir.declarations.AMethodDeclIR;
13:
14: public class RecClassInfo
15: {
16:         private List<ADefaultClassDeclIR> recClasses;
17:         private Set<SDeclIR> members;
18:
19:         public RecClassInfo()
20:         {
21:                 this.recClasses = new LinkedList<>();
22:                 this.members = new HashSet<SDeclIR>();
23:         }
24:
25:         public void register(SDeclIR acc)
26:         {
27:•                if (!contains(acc))
28:                 {
29:                         members.add(acc);
30:                 }
31:         }
32:
33:         private boolean contains(SDeclIR memberToCheck)
34:         {
35:•                for (SDeclIR m : members)
36:                 {
37:•                        if (m == memberToCheck)
38:                         {
39:                                 return true;
40:                         }
41:                 }
42:
43:                 return false;
44:         }
45:
46:         public void updateAccessor(AMethodDeclIR oldAcc, AMethodDeclIR newAcc)
47:         {
48:                 SDeclIR toRemove = null;
49:
50:•                for (SDeclIR m : members)
51:                 {
52:•                        if (m == oldAcc)
53:                         {
54:                                 toRemove = m;
55:                                 break;
56:                         }
57:                 }
58:
59:•                if (toRemove != null)
60:                 {
61:                         members.remove(toRemove);
62:                         members.add(newAcc);
63:                 }
64:         }
65:
66:         public boolean isRecField(AFieldDeclIR field)
67:         {
68:                 return contains(field);
69:         }
70:
71:         public boolean inAccessor(INode node)
72:         {
73:                 AMethodDeclIR anc = node.getAncestor(AMethodDeclIR.class);
74:
75:•                if (anc == null)
76:                 {
77:                         return false;
78:                 }
79:
80:                 return contains(anc);
81:         }
82:
83:         public boolean inRecConstructor(INode node)
84:         {
85:•                if (!inRec(node))
86:                 {
87:                         return false;
88:                 }
89:
90:                 AMethodDeclIR m = node.getAncestor(AMethodDeclIR.class);
91:
92:•                if (m != null)
93:                 {
94:                         return m.getIsConstructor();
95:                 }
96:
97:                 return false;
98:         }
99:
100:         public boolean inRec(INode node)
101:         {
102:                 ADefaultClassDeclIR clazz = node.getAncestor(ADefaultClassDeclIR.class);
103:
104:•                if (clazz == null)
105:                 {
106:                         return false;
107:                 }
108:
109:•                for (ADefaultClassDeclIR r : recClasses)
110:                 {
111:•                        if (clazz == r)
112:                         {
113:                                 return true;
114:                         }
115:                 }
116:
117:                 return false;
118:         }
119:
120:         public void registerRecClass(ADefaultClassDeclIR recClass)
121:         {
122:                 recClasses.add(recClass);
123:         }
124: }