Package: VdmDebugManager

VdmDebugManager

nameinstructionbranchcomplexitylinemethod
VdmDebugManager()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getInstance()
M: 8 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getTypeFactory()
M: 8 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getVariableNameComparator()
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%
static {...}
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * org.overture.ide.debug
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.ide.debug.core;
23:
24: import java.util.Comparator;
25:
26: import org.overture.ide.debug.core.model.IVdmTypeFactory;
27: import org.overture.ide.debug.core.model.internal.VdmTypeFactory;
28:
29: public class VdmDebugManager
30: {
31:         // private static final String VDM_DEBUG_MODEL_EXT_POINT = VdmDebugPlugin.PLUGIN_ID
32:         //                        + ".VdmDebugModel"; //$NON-NLS-1$
33:         //        private static final String NATURE_ID = "natureId"; //$NON-NLS-1$
34:         //        private static final String DEBUG_MODEL_ID = "debugModelId"; //$NON-NLS-1$
35:         //        private static final String TYPE_FACTORY = "typeFactory"; //$NON-NLS-1$
36:         //        private static final String VARIABLE_NAME_COMPARATOR = "variableNameComparator"; //$NON-NLS-1$
37:         //        private static final String DEBUG_TOOLKIT = "debugToolkit"; //$NON-NLS-1$
38:
39:         private static VdmDebugManager instance;
40:         private static VdmTypeFactory typeFactory = null;
41:
42:         public static synchronized VdmDebugManager getInstance()
43:         {
44:•                if (instance == null)
45:                 {
46:                         instance = new VdmDebugManager();
47:                 }
48:
49:                 return instance;
50:         }
51:
52:         // private final Map<String,Info> natureToInfoMap = new HashMap<String,Info>();
53:         // private final Map<String,String> modelToNatureMap = new HashMap<String,String>();
54:
55:         // private static class Info {
56:         // public final String debugModelId;
57:         // public final IVdmTypeFactory typeFactory;
58:         // public final Comparator comparator;
59:         // // public final IDLTKDebugToolkit debugToolkit;
60:         //
61:         // public Info(String debugModelId, IVdmTypeFactory typeFactory,
62:         // Comparator comparator) {
63:         // this.debugModelId = debugModelId;
64:         // this.typeFactory = typeFactory;
65:         //
66:         // this.comparator = comparator;
67:         // }
68:         // }
69:
70:         public Comparator<Object> getVariableNameComparator()
71:         {
72:                 return new VdmVariableNameComparator();
73:         }
74:
75:         public IVdmTypeFactory getTypeFactory()
76:         {
77:
78:•                if (typeFactory == null)
79:                 {
80:                         typeFactory = new VdmTypeFactory();
81:                 }
82:                 return typeFactory;
83:         }
84:
85:         // private void loadExtenstionPoints() {
86:         // IExtensionRegistry registry = Platform.getExtensionRegistry();
87:         // IExtension[] extensions = registry.getExtensionPoint(
88:         // VDM_DEBUG_MODEL_EXT_POINT).getExtensions();
89:         //
90:         // for (int i = 0; i < extensions.length; i++) {
91:         // IExtension extension = extensions[i];
92:         // IConfigurationElement[] elements = extension
93:         // .getConfigurationElements();
94:         //
95:         // if (elements.length > 0) {
96:         // IConfigurationElement element = elements[0];
97:         // final String natureId = element.getAttribute(NATURE_ID);
98:         // final String debugModelId = element
99:         // .getAttribute(DEBUG_MODEL_ID);
100:         //
101:         // IVdmTypeFactory typeFactory = null;
102:         //
103:         // try {
104:         // typeFactory = (IVdmTypeFactory) element
105:         // .createExecutableExtension(TYPE_FACTORY);
106:         // } catch (CoreException e) {
107:         // VdmDebugPlugin.log(e);
108:         // }
109:         //
110:         // Comparator comparator = null;
111:         // String comparatorId = element
112:         // .getAttribute(VARIABLE_NAME_COMPARATOR);
113:         // if (comparatorId != null) {
114:         // try {
115:         // comparator = (Comparator) element
116:         // .createExecutableExtension(VARIABLE_NAME_COMPARATOR);
117:         // } catch (CoreException e) {
118:         // VdmDebugPlugin.log(e);
119:         // }
120:         // }
121:         // if (comparator == null) {
122:         // comparator = new VariableNameComparator();
123:         // }
124:         // //// IDLTKDebugToolkit debugToolkit = null;
125:         // // if (element.getAttribute(DEBUG_TOOLKIT) != null) {
126:         // // try {
127:         // // debugToolkit = (IDLTKDebugToolkit) element
128:         // // .createExecutableExtension(DEBUG_TOOLKIT);
129:         // // } catch (Exception e) {
130:         // // DLTKDebugPlugin.log(e);
131:         // // }
132:         // // }
133:         // // if (debugToolkit == null) {
134:         // // debugToolkit = new DefaultDebugToolkit();
135:         // // }
136:         //
137:         // if (natureId != null && debugModelId != null) {
138:         // natureToInfoMap.put(natureId, new Info(debugModelId,
139:         // typeFactory, comparator));
140:         // modelToNatureMap.put(debugModelId, natureId);
141:         // }
142:         // }
143:         //
144:         // }
145:         //
146:         //
147:         //
148:         // }
149:
150:         // private static class DefaultDebugToolkit extends AbstractVdmDebugToolkit {
151:         //
152:         // }
153:         //
154:         // protected Info getInfo(String natureId) {
155:         // return (Info) natureToInfoMap.get(natureId);
156:         // }
157:         //
158:         // protected VdmDebugManager() {
159:         // natureToInfoMap = new HashMap();
160:         // modelToNatureMap = new HashMap();
161:         //
162:         // loadExtenstionPoints();
163:         // }
164:         //
165:         // public String getNatureByDebugModel(String debugModelId) {
166:         // return (String) modelToNatureMap.get(debugModelId);
167:         // }
168:         //
169:         // public String getDebugModelByNature(String natureId) {
170:         // return getInfo(natureId).debugModelId;
171:         // }
172:         //
173:         // public IVdmTypeFactory getTypeFactoryByNature(String natureId) {
174:         // return getInfo(natureId).typeFactory;
175:         // }
176:         //
177:         // public IVdmTypeFactory getTypeFactoryByDebugModel(String debugModelId) {
178:         // return getTypeFactoryByNature(getNatureByDebugModel(debugModelId));
179:         // }
180:         //
181:         //
182:         //
183:         // public Comparator getVariableNameComparatorByDebugModel(String debugModelId) {
184:         // return getVariableNameComparatorByNature(getNatureByDebugModel(debugModelId));
185:         // }
186:         //
187:         // public IDLTKDebugToolkit getDebugToolkitByNature(String natureId) {
188:         // return getInfo(natureId).debugToolkit;
189:         // }
190:         //
191:         // public IDLTKDebugToolkit getDebugToolkitByDebugModel(String debugModelId) {
192:         // return getDebugToolkitByNature(getNatureByDebugModel(debugModelId));
193:         // }
194: }