Package: PrivateClassEnvironment

PrivateClassEnvironment

nameinstructionbranchcomplexitylinemethod
PrivateClassEnvironment(ITypeCheckerAssistantFactory, SClassDefinition)
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%
PrivateClassEnvironment(ITypeCheckerAssistantFactory, SClassDefinition, 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%
findClassDefinition()
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%
findMatches(ILexNameToken)
M: 0 C: 20
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 4
100%
M: 0 C: 1
100%
findName(ILexNameToken, NameScope)
M: 0 C: 27
100%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 0 C: 4
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: 2 C: 22
92%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 4
100%
M: 0 C: 1
100%
getDefinitions()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 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: 0 C: 16
100%
M: 0 C: 6
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
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.List;
27: import java.util.Set;
28:
29: import org.overture.ast.definitions.ABusClassDefinition;
30: import org.overture.ast.definitions.ACpuClassDefinition;
31: import org.overture.ast.definitions.AStateDefinition;
32: import org.overture.ast.definitions.ASystemClassDefinition;
33: import org.overture.ast.definitions.PDefinition;
34: import org.overture.ast.definitions.SClassDefinition;
35: import org.overture.ast.intf.lex.ILexNameToken;
36: import org.overture.ast.typechecker.NameScope;
37: import org.overture.typechecker.assistant.ITypeCheckerAssistantFactory;
38:
39: /**
40: * Define the type checking environment for a class as observed from inside.
41: */
42:
43: public class PrivateClassEnvironment extends Environment
44: {
45:         public List<PDefinition> getDefinitions()
46:         {
47:                 return classdef.getDefinitions();
48:         }
49:
50:         private final SClassDefinition classdef;
51:
52:         public PrivateClassEnvironment(ITypeCheckerAssistantFactory af,
53:                         SClassDefinition classdef)
54:         {
55:                 super(af, null);
56:                 this.classdef = classdef;
57:         }
58:
59:         public PrivateClassEnvironment(ITypeCheckerAssistantFactory af,
60:                         SClassDefinition classdef, Environment env)
61:         {
62:                 super(af, env);
63:                 this.classdef = classdef;
64:         }
65:
66:         @Override
67:         public PDefinition findName(ILexNameToken sought, NameScope scope)
68:         {
69:                 PDefinition def = af.createPDefinitionAssistant().findName(classdef, sought, scope);
70:
71:•                if (def != null && !ExcludedDefinitions.isExcluded(def))
72:                 {
73:                         return def;
74:                 }
75:
76:•                return outer == null ? null : outer.findName(sought, scope);
77:         }
78:
79:         @Override
80:         public PDefinition findType(ILexNameToken name, String fromModule)
81:         {
82:                 // FIXME: Here the SClassDefinitionAssistantTC is used so I can't delete the method from the assistant
83:                 // What is the strategy in this case?
84:                 PDefinition def = af.createPDefinitionAssistant().findType(classdef, name, null);
85:                 // classdef.apply(af.getDefinitionFinder(),new DefinitionFinder.Newquestion(name, null));
86:                 // SClassDefinitionAssistantTC.findType(classdef, name, null);
87:
88:•                if (def != null)
89:                 {
90:                         return def;
91:                 }
92:
93:•                return outer == null ? null : outer.findType(name, null);
94:         }
95:
96:         @Override
97:         public Set<PDefinition> findMatches(ILexNameToken name)
98:         {
99:                 Set<PDefinition> defs = af.createSClassDefinitionAssistant().findMatches(classdef, name);
100:
101:•                if (outer != null)
102:                 {
103:                         defs.addAll(outer.findMatches(name));
104:                 }
105:
106:                 return defs;
107:         }
108:
109:         @Override
110:         public void unusedCheck()
111:         {
112:                 af.createPDefinitionAssistant().unusedCheck(classdef);
113:         }
114:
115:         @Override
116:         public AStateDefinition findStateDefinition()
117:         {
118:                 return null;
119:         }
120:
121:         @Override
122:         public boolean isVDMPP()
123:         {
124:                 return true;
125:         }
126:
127:         @Override
128:         public boolean isSystem()
129:         {
130:•                return classdef instanceof ASystemClassDefinition
131:                                 || classdef instanceof ACpuClassDefinition
132:                                 || classdef instanceof ABusClassDefinition;
133:         }
134:
135:         @Override
136:         public SClassDefinition findClassDefinition()
137:         {
138:                 return classdef;
139:         }
140:
141:         @Override
142:         public boolean isStatic()
143:         {
144:                 return false;
145:         }
146:
147: }