Package: PublicClassEnvironment

PublicClassEnvironment

nameinstructionbranchcomplexitylinemethod
PublicClassEnvironment(ITypeCheckerAssistantFactory, List)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
PublicClassEnvironment(ITypeCheckerAssistantFactory, List, Environment)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
PublicClassEnvironment(ITypeCheckerAssistantFactory, SClassDefinition)
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
PublicClassEnvironment(ITypeCheckerAssistantFactory, SClassDefinition, Environment)
M: 15 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
findClassDefinition()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
findMatches(ILexNameToken)
M: 7 C: 13
65%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 3
75%
M: 0 C: 1
100%
findName(ILexNameToken, NameScope)
M: 5 C: 29
85%
M: 2 C: 6
75%
M: 2 C: 3
60%
M: 0 C: 6
100%
M: 0 C: 1
100%
findStateDefinition()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
findType(ILexNameToken, String)
M: 5 C: 25
83%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 0 C: 5
100%
M: 0 C: 1
100%
getDefinitions()
M: 22 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
isStatic()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isSystem()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isVDMPP()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
unusedCheck()
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: *
3: *        Copyright (c) 2008 Fujitsu Services Ltd.
4: *
5: *        Author: Nick Battle
6: *
7: *        This file is part of VDMJ.
8: *
9: *        VDMJ is free software: you can redistribute it and/or modify
10: *        it under the terms of the GNU General Public License as published by
11: *        the Free Software Foundation, either version 3 of the License, or
12: *        (at your option) any later version.
13: *
14: *        VDMJ is distributed in the hope that it will be useful,
15: *        but WITHOUT ANY WARRANTY; without even the implied warranty of
16: *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: *        GNU General Public License for more details.
18: *
19: *        You should have received a copy of the GNU General Public License
20: *        along with VDMJ. If not, see <http://www.gnu.org/licenses/>.
21: *
22: ******************************************************************************/
23:
24: package org.overture.typechecker;
25:
26: import java.util.LinkedList;
27: import java.util.List;
28: import java.util.Set;
29: import java.util.Vector;
30:
31: import org.overture.ast.definitions.AStateDefinition;
32: import org.overture.ast.definitions.PDefinition;
33: import org.overture.ast.definitions.SClassDefinition;
34: import org.overture.ast.intf.lex.ILexNameToken;
35: import org.overture.ast.typechecker.NameScope;
36: import org.overture.typechecker.assistant.ITypeCheckerAssistantFactory;
37:
38: /**
39: * Define the type checking environment for a set of classes, as observed from the outside.
40: */
41:
42: public class PublicClassEnvironment extends Environment
43: {
44:
45:         private final List<SClassDefinition> classes;
46:
47:         public List<PDefinition> getDefinitions()
48:         {
49:                 List<PDefinition> res = new LinkedList<PDefinition>();
50:•                for (PDefinition d : classes)
51:                 {
52:                         res.add(d);
53:                 }
54:                 return res;
55:         }
56:
57:         public PublicClassEnvironment(ITypeCheckerAssistantFactory af,
58:                         List<SClassDefinition> classes)
59:         {
60:                 super(af, null);
61:                 this.classes = classes;
62:         }
63:
64:         public PublicClassEnvironment(ITypeCheckerAssistantFactory af,
65:                         List<SClassDefinition> classes, Environment env)
66:         {
67:                 super(af, env);
68:                 this.classes = classes;
69:         }
70:
71:         public PublicClassEnvironment(ITypeCheckerAssistantFactory af,
72:                         SClassDefinition one)
73:         {
74:                 super(af, null);
75:                 this.classes = new Vector<SClassDefinition>();
76:                 this.classes.add(one);
77:         }
78:
79:         public PublicClassEnvironment(ITypeCheckerAssistantFactory af,
80:                         SClassDefinition one, Environment env)
81:         {
82:                 super(af, env);
83:                 this.classes = new Vector<SClassDefinition>();
84:                 this.classes.add(one);
85:         }
86:
87:         @Override
88:         public PDefinition findName(ILexNameToken name, NameScope scope)
89:         {
90:                 PDefinition def = af.createSClassDefinitionAssistant().findName(classes, name, scope);
91:
92:•                if (def != null
93:•                                && af.createPAccessSpecifierAssistant().isPublic(def.getAccess())
94:•                                && !ExcludedDefinitions.isExcluded(def))
95:                 {
96:                         return def;
97:                 }
98:
99:•                return outer == null ? null : outer.findName(name, scope);
100:         }
101:
102:         @Override
103:         public PDefinition findType(ILexNameToken name, String fromModule)
104:         {
105:                 PDefinition def = af.createSClassDefinitionAssistant().findType(classes, name);
106:
107:•                if (def != null
108:•                                && af.createPAccessSpecifierAssistant().isPublic(def.getAccess()))
109:                 {
110:                         return def;
111:                 }
112:
113:•                return outer == null ? null : outer.findType(name, null);
114:         }
115:
116:         @Override
117:         public Set<PDefinition> findMatches(ILexNameToken name)
118:         {
119:                 Set<PDefinition> defs = af.createSClassDefinitionAssistant().findMatches(classes, name);
120:
121:•                if (outer != null)
122:                 {
123:                         defs.addAll(outer.findMatches(name));
124:                 }
125:
126:                 return defs;
127:         }
128:
129:         @Override
130:         public void unusedCheck()
131:         {
132:                 af.createSClassDefinitionAssistant().unusedCheck(classes);
133:         }
134:
135:         @Override
136:         public AStateDefinition findStateDefinition()
137:         {
138:                 return null;
139:         }
140:
141:         @Override
142:         public boolean isVDMPP()
143:         {
144:                 return true;
145:         }
146:
147:         @Override
148:         public boolean isSystem()
149:         {
150:                 return false; // See PrivateClassEnvironment
151:         }
152:
153:         @Override
154:         public SClassDefinition findClassDefinition()
155:         {
156:                 return null;
157:         }
158:
159:         @Override
160:         public boolean isStatic()
161:         {
162:                 return false;
163:         }
164:
165: }