Package: PAccessSpecifierAssistantTC

PAccessSpecifierAssistantTC

nameinstructionbranchcomplexitylinemethod
PAccessSpecifierAssistantTC(ITypeCheckerAssistantFactory)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getStatic(PDefinition, boolean)
M: 14 C: 21
60%
M: 6 C: 4
40%
M: 4 C: 2
33%
M: 2 C: 4
67%
M: 0 C: 1
100%
isAsync(PAccessSpecifier)
M: 2 C: 13
87%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 1 C: 3
75%
M: 0 C: 1
100%
isPrivate(AAccessSpecifierAccessSpecifier)
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%
isProtected(PAccessSpecifier)
M: 12 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
isPublic(PAccessSpecifier)
M: 12 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
isStatic(AAccessSpecifierAccessSpecifier)
M: 0 C: 7
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
narrowerThan(AAccessSpecifierAccessSpecifier, AAccessSpecifierAccessSpecifier)
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%
narrowerThan(PAccess, PAccess)
M: 9 C: 21
70%
M: 3 C: 7
70%
M: 2 C: 4
67%
M: 2 C: 6
75%
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: /*
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.assistant.definition;
23:
24: import org.overture.ast.assistant.IAstAssistant;
25: import org.overture.ast.assistant.definition.PAccessSpecifierAssistant;
26: import org.overture.ast.definitions.APrivateAccess;
27: import org.overture.ast.definitions.AProtectedAccess;
28: import org.overture.ast.definitions.APublicAccess;
29: import org.overture.ast.definitions.PAccess;
30: import org.overture.ast.definitions.PDefinition;
31: import org.overture.ast.factory.AstFactory;
32: import org.overture.ast.types.AAccessSpecifierAccessSpecifier;
33: import org.overture.ast.types.PAccessSpecifier;
34: import org.overture.typechecker.assistant.ITypeCheckerAssistantFactory;
35:
36:•public class PAccessSpecifierAssistantTC extends PAccessSpecifierAssistant implements IAstAssistant
37: {
38:         protected ITypeCheckerAssistantFactory af;
39:
40:         public PAccessSpecifierAssistantTC(ITypeCheckerAssistantFactory af)
41:         {
42:                 super(af);
43:                 this.af = af;
44:         }
45:
46:         public boolean isPublic(PAccessSpecifier access)
47:         {
48:•                if (access instanceof AAccessSpecifierAccessSpecifier)
49:                 {
50:                         AAccessSpecifierAccessSpecifier a = (AAccessSpecifierAccessSpecifier) access;
51:                         return a.getAccess() instanceof APublicAccess;
52:                 }
53:                 return false;
54:         }
55:
56:         public boolean isPrivate(AAccessSpecifierAccessSpecifier access)
57:         {
58:                 return access.getAccess() instanceof APrivateAccess;
59:         }
60:
61:         public boolean isProtected(PAccessSpecifier access)
62:         {
63:•                if (access instanceof AAccessSpecifierAccessSpecifier)
64:                 {
65:                         AAccessSpecifierAccessSpecifier a = (AAccessSpecifierAccessSpecifier) access;
66:                         return a.getAccess() instanceof AProtectedAccess;
67:                 }
68:                 return false;
69:         }
70:
71:         public boolean isStatic(AAccessSpecifierAccessSpecifier access)
72:         {
73:
74:•                return access.getStatic() != null;
75:         }
76:
77:         public boolean isAsync(PAccessSpecifier access)
78:         {
79:•                if (access instanceof AAccessSpecifierAccessSpecifier)
80:                 {
81:                         AAccessSpecifierAccessSpecifier a = (AAccessSpecifierAccessSpecifier) access;
82:•                        return a.getAsync() != null;
83:                 }
84:                 return false;
85:         }
86:
87:         public boolean narrowerThan(AAccessSpecifierAccessSpecifier access,
88:                         AAccessSpecifierAccessSpecifier other)
89:         {
90:                 return narrowerThan(access.getAccess(), other.getAccess());
91:
92:         }
93:
94:         private boolean narrowerThan(PAccess access, PAccess other)
95:         {
96:•                if (access instanceof APrivateAccess)
97:                 {
98:•                        return !(other instanceof APrivateAccess);
99:•                } else if (access instanceof AProtectedAccess)
100:                 {
101:                         return other instanceof APublicAccess;
102:•                } else if (access instanceof APublicAccess)
103:                 {
104:                         return false;
105:                 }
106:•                assert false : "PAccessSpecifierAssistent : narrowerThan PAccess switch is not comprehensive";
107:                 return false;
108:         }
109:
110:         public AAccessSpecifierAccessSpecifier getStatic(PDefinition d,
111:                         boolean asStatic)
112:         {
113:                 AAccessSpecifierAccessSpecifier paccess = d.getAccess();
114:•                if (paccess instanceof AAccessSpecifierAccessSpecifier)
115:                 {
116:•                        return AstFactory.newAAccessSpecifierAccessSpecifier(paccess.getAccess().clone(), asStatic
117:•                                        && paccess.getStatic() != null, paccess.getAsync() != null, false);
118:                 }
119:•                assert false : "PAccessSpecifier must be instance of AAccessSpecifierAccessSpecifier";
120:                 return null;
121:
122:         }
123:
124: }