Package: VdmSlMainLaunchConfigurationTab

VdmSlMainLaunchConfigurationTab

nameinstructionbranchcomplexitylinemethod
VdmSlMainLaunchConfigurationTab()
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%
getExpression(String, String, boolean)
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getModuleLabelName()
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%
isSupported(IProject)
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%
validateTypes(IVdmProject, String)
M: 78 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 23 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * org.overture.ide.vdmsl.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.vdmsl.debug.ui.launching;
23:
24: import org.eclipse.core.resources.IProject;
25: import org.eclipse.core.runtime.CoreException;
26:
27: import org.overture.ast.lex.Dialect;
28: import org.overture.ast.util.modules.ModuleList;
29: import org.overture.config.Settings;
30: import org.overture.ide.core.IVdmModel;
31: import org.overture.ide.core.ast.NotAllowedException;
32: import org.overture.ide.core.resources.IVdmProject;
33: import org.overture.ide.debug.ui.launching.AbstractVdmMainLaunchConfigurationTab;
34: import org.overture.ide.ui.utility.VdmTypeCheckerUi;
35: import org.overture.ide.vdmsl.debug.Activator;
36: import org.overture.ide.vdmsl.debug.utils.VdmSlRuntimeUtil;
37: import org.overture.ide.vdmsl.core.IVdmSlCoreConstants;
38: import org.overture.parser.messages.Console;
39: import org.overture.parser.messages.VDMErrorsException;
40:
41: public class VdmSlMainLaunchConfigurationTab extends
42:                 AbstractVdmMainLaunchConfigurationTab
43: {
44:
45:         @Override
46:         protected String getExpression(String module, String operation,
47:                         boolean isStatic)
48:         {
49:                 return module + STATIC_CALL_SEPERATOR + operation;
50:         }
51:
52:         @Override
53:         protected boolean isSupported(IProject project) throws CoreException
54:         {
55:                 return project.hasNature(IVdmSlCoreConstants.NATURE);
56:         }
57:
58:         @Override
59:         protected boolean validateTypes(IVdmProject project, String expression)
60:         {
61:                 try
62:                 {
63:                         Settings.dialect = Dialect.VDM_SL;
64:                         Settings.release = project.getLanguageVersion();
65:                         Settings.strict = project.hasUseStrictLetDef();
66:                         Console.charset = getProject().getDefaultCharset();
67:                         IVdmModel model = project.getModel();
68:•                        if (!model.isTypeCorrect())
69:                         {
70:•                                if (!VdmTypeCheckerUi.typeCheck(getShell(), project))
71:                                 {
72:                                         setErrorMessage("Type errors in Model");
73:                                         return false;
74:                                 }
75:                         }
76:                         ModuleList modules = model.getModuleList();
77: //                        modules.combineDefaults();
78: //                        ModuleInterpreter ci = new ModuleInterpreter(modules);
79: //                        if (expression.contains(STATIC_CALL_SEPERATOR))
80: //                        {
81: //                                ci.setDefaultName(expression.substring(0, expression.indexOf(STATIC_CALL_SEPERATOR))); // needed for static fn/op check
82: //                        }
83: //
84: //                        ci.typeCheck(expression);
85: //                        return true;
86:                         return VdmSlRuntimeUtil.typeCheck(modules, expression);
87:                 } catch (NotAllowedException e)
88:                 {
89:                         setErrorMessage(e.toString());
90:                         e.printStackTrace();
91:                 } catch (VDMErrorsException e)
92:                 {
93:                         setErrorMessage(e.toString());
94:                 } catch (Exception e)
95:                 {
96:•                        if (e.getMessage() != null && e.getMessage().contains("not loaded"))
97:                         {
98:                                 setErrorMessage(e.getMessage());
99:                         }
100:                         else
101:                         {
102:                                 Activator.logError("Internal type check error", e);
103:                                 setErrorMessage("Internal type check error: " + e.toString());
104:                         }
105:                 }
106:
107:                 return false;
108:         }
109:         
110:         @Override
111:         protected String getModuleLabelName()
112:         {
113:                 return "Module";
114:         }
115:
116: }