Package: VdmPpMainLaunchConfigurationTab

VdmPpMainLaunchConfigurationTab

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