Package: BuilderPp

BuilderPp

nameinstructionbranchcomplexitylinemethod
BuilderPp()
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
buildModel(IVdmModel)
M: 25 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
typeCheck()
M: 52 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 20 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * org.overture.ide.builders.vdmj
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.builders.vdmj;
23:
24: import org.eclipse.core.runtime.CoreException;
25: import org.eclipse.core.runtime.IStatus;
26: import org.overture.ast.lex.Dialect;
27: import org.overture.ast.messages.InternalException;
28: import org.overture.ast.util.definitions.ClassList;
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.typechecker.ClassTypeChecker;
33: import org.overture.typechecker.TypeCheckException;
34: import org.overture.typechecker.TypeChecker;
35:
36: /***
37: * VDM PP builder
38: *
39: * @author kela <extension<br>
40: * point="org.overture.ide.builder"><br>
41: * <builder<br>
42: * class="org.overture.ide.builders.vdmj.BuilderPp"><br>
43: * </builder><br>
44: * </extension><br>
45: */
46: public class BuilderPp extends VdmjBuilder {
47:         protected ClassList classes = new ClassList();
48:
49:         public BuilderPp() {
50:                 Settings.dialect = Dialect.VDM_PP;
51:         }
52:
53:         
54:         @Override
55:         public IStatus buildModel(IVdmModel rooList)
56:         {
57:         
58:                 try
59:                 {
60:                         Settings.release = getProject().getLanguageVersion();
61:                         Settings.strict = getProject().hasUseStrictLetDef();
62:                 } catch (CoreException e1)
63:                 {
64:                         e1.printStackTrace();
65:                 }
66:                 try {
67:                         classes = rooList.getClassList();
68:                 } catch (NotAllowedException e) {
69:                         
70:                         e.printStackTrace();
71:                 }
72:
73:                 return buildModel(getProject());
74:
75:         }
76:
77:         
78:
79:
80:
81:         /**
82:          * @see org.overture.vdmj.VDMJ#typeCheck()
83:          */
84:
85:         @Override
86:         public ExitStatus typeCheck() {
87:                 int terrs = 0;
88:
89:                 try {
90:                         
91:                 TypeChecker typeChecker = new ClassTypeChecker(classes);
92:                         typeChecker.typeCheck();
93:                 } catch (InternalException e) {
94:                         processInternalError(e);
95:                 terrs++;
96:                 }catch(TypeCheckException e){
97:                 //is already in TypeChecker Errors
98:                         terrs++;
99:                 }catch (Throwable e) {
100:                         processInternalError(e);
101:
102:•                        if (e instanceof StackOverflowError) {
103:                                 e.printStackTrace();
104:                         }
105:
106:                         terrs++;
107:                 }
108:
109:                 terrs += TypeChecker.getErrorCount();
110:
111:•                if (terrs > 0) {
112:
113:                         processErrors(TypeChecker.getErrors());
114:                 }
115:
116:                 int twarn = TypeChecker.getWarningCount();
117:
118:•                if (twarn > 0) {
119:
120:                         processWarnings(TypeChecker.getWarnings());
121:                 }
122:
123:•                return terrs == 0 ? ExitStatus.EXIT_OK : ExitStatus.EXIT_ERRORS;
124:         }
125:
126:
127:
128: }