Package: UnusedChecker

UnusedChecker

nameinstructionbranchcomplexitylinemethod
UnusedChecker(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%
caseAEqualsDefinition(AEqualsDefinition)
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%
caseAMultiBindListDefinition(AMultiBindListDefinition)
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%
caseAStateDefinition(AStateDefinition)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
caseAValueDefinition(AValueDefinition)
M: 0 C: 25
100%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 0 C: 7
100%
M: 0 C: 1
100%
defaultPDefinition(PDefinition)
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%

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.utilities;
23:
24: import org.overture.ast.analysis.AnalysisAdaptor;
25: import org.overture.ast.analysis.AnalysisException;
26: import org.overture.ast.definitions.AEqualsDefinition;
27: import org.overture.ast.definitions.AMultiBindListDefinition;
28: import org.overture.ast.definitions.AStateDefinition;
29: import org.overture.ast.definitions.AValueDefinition;
30: import org.overture.ast.definitions.PDefinition;
31: import org.overture.typechecker.assistant.ITypeCheckerAssistantFactory;
32:
33: /**
34: * This class checks if a node is used.
35: *
36: * @author kel
37: */
38: public class UnusedChecker extends AnalysisAdaptor
39: {
40:
41:         protected ITypeCheckerAssistantFactory af;
42:
43:         public UnusedChecker(ITypeCheckerAssistantFactory af)
44:         {
45:                 this.af = af;
46:         }
47:
48:         @Override
49:         public void caseAEqualsDefinition(AEqualsDefinition node)
50:                         throws AnalysisException
51:         {
52:•                if (node.getDefs() != null)
53:                 {
54:                         af.createPDefinitionListAssistant().unusedCheck(node.getDefs());
55:                 }
56:         }
57:
58:         @Override
59:         public void caseAMultiBindListDefinition(AMultiBindListDefinition node)
60:                         throws AnalysisException
61:         {
62:•                if (node.getDefs() != null)
63:                 {
64:                         af.createPDefinitionListAssistant().unusedCheck(node.getDefs());
65:                 }
66:         }
67:
68:         @Override
69:         public void caseAStateDefinition(AStateDefinition node)
70:                         throws AnalysisException
71:         {
72:                 af.createPDefinitionListAssistant().unusedCheck(node.getStateDefs());
73:         }
74:
75:         @Override
76:         public void caseAValueDefinition(AValueDefinition node)
77:                         throws AnalysisException
78:         {
79:•                if (node.getUsed()) // Indicates all definitions exported (used)
80:                 {
81:                         return;
82:                 }
83:
84:•                if (node.getDefs() != null)
85:                 {
86:•                        for (PDefinition def : node.getDefs())
87:                         {
88:                                 // PDefinitionAssistantTC.unusedCheck(def);
89:                                 def.apply(THIS);
90:                         }
91:                 }
92:
93:         }
94:
95:         @Override
96:         public void defaultPDefinition(PDefinition node) throws AnalysisException
97:         {
98:                 af.createPDefinitionAssistant().unusedCheckBaseCase(node);
99:         }
100:
101: }