Package: VdmRtMainLaunchConfigurationTab

VdmRtMainLaunchConfigurationTab

nameinstructionbranchcomplexitylinemethod
VdmRtMainLaunchConfigurationTab()
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: 79 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.vdmrt.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.vdmrt.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.debug.utils.VdmPpRuntimeUtil;
35: import org.overture.ide.vdmrt.debug.Activator;
36: import org.overture.ide.vdmrt.core.IVdmRtCoreConstants;
37: import org.overture.parser.messages.Console;
38: import org.overture.parser.messages.VDMErrorsException;
39:
40: public class VdmRtMainLaunchConfigurationTab 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(IVdmRtCoreConstants.NATURE);
60:         }
61:
62:         @Override
63:         protected boolean validateTypes(IVdmProject project, String expression)
64:         {
65:                 try
66:                 {
67:                         Settings.dialect = Dialect.VDM_RT;
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: //                        ClassInterpreter ci = new ClassInterpreter(classes);
82: //                        
83: //                        //Fix to the lauchConfig type check expression
84: //                        ci.setDefaultName(null);
85: //                        ci.typeCheck(expression);
86: //                        return true;
87:                         return VdmPpRuntimeUtil.typeCheck(classes, expression, Dialect.VDM_RT);
88:                 } catch (NotAllowedException e)
89:                 {
90:                         setErrorMessage(e.toString());
91:                         e.printStackTrace();
92:                 } catch (VDMErrorsException e)
93:                 {
94:                         setErrorMessage(e.toString());
95:                 } catch (Exception e)
96:                 {
97:•                        if (e.getMessage() != null && e.getMessage().contains("not loaded"))
98:                         {
99:                                 setErrorMessage(e.getMessage());
100:                         }
101:                         else
102:                         {
103:                                 Activator.logError("Internal type check error", e);
104:                                 setErrorMessage("Internal type check error: " + e.toString());
105:                         }
106:                 }
107:
108:                 return false;
109:         }
110:
111:         // protected Collection<? extends String> getOptionalArguments(
112:         // IProject project, InterpreterConfig config, ILaunch launch)
113:         // {
114:         // // log
115:         // List<String> arguments = new ArrayList<String>();
116:         // DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
117:         // Date date = new Date();
118:         // File logDir = new File(new File(getOutputFolder(config),"logs"), launch.getLaunchConfiguration().getName());
119:         // logDir.mkdirs();
120:         // String logFilename = dateFormat.format(date) + ".logrt";
121:         // System.out.println(logFilename);
122:         // File f = new File(logDir, logFilename);
123:         // if (!f.exists())
124:         // {
125:         // f.getParentFile().mkdirs();
126:         // try
127:         // {
128:         // f.createNewFile();
129:         // } catch (IOException e)
130:         // {
131:         //
132:         // e.printStackTrace();
133:         // }
134:         // }
135:         //
136:         // arguments.add("-log");
137:         // arguments.add(logDir.toURI().toASCIIString() + logFilename);
138:         // try
139:         // {
140:         // project.refreshLocal(IProject.DEPTH_INFINITE, null);
141:         // } catch (CoreException e)
142:         // {
143:         //
144:         // e.printStackTrace();
145:         // }
146:         // return arguments;
147:         // }
148:
149: }