Package: VdmModelWorkingCopy

VdmModelWorkingCopy

nameinstructionbranchcomplexitylinemethod
VdmModelWorkingCopy(VdmModel)
M: 40 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%
commit()
M: 43 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
discard()
M: 19 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
fireModelCheckedEvent()
M: 1 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.core
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.core.ast;
23:
24: import org.overture.ide.core.IVdmModel;
25: import org.overture.ide.core.resources.IVdmSourceUnit;
26: import org.overture.ide.core.resources.VdmSourceUnitWorkingCopy;
27:
28: public class VdmModelWorkingCopy extends VdmModel implements IVdmModel
29: {
30:         VdmModel sourceModel;
31:         boolean discarded = false;
32: //FIXME: state!!
33:         public VdmModelWorkingCopy(VdmModel sourceModel)
34:         {
35:                 this.sourceModel = sourceModel;
36:•                for (IVdmSourceUnit source : sourceModel.getSourceUnits())
37:                 {
38:                         this.addVdmSourceUnit(source.getWorkingCopy());
39:                 }
40:                 
41:                 
42:                 this.isTypeChecked = sourceModel.isTypeChecked;
43:                 this.isTypeCorrect = sourceModel.isTypeCorrect;
44:                 this.workingCopyNotCommitedCount = 0;
45:
46:                 this.checkedTime= sourceModel.checkedTime;
47:
48:                 
49:         }
50:
51:         public synchronized void commit()
52:         {
53:•                if(discarded)
54:                 {
55:                         return;
56:                 }
57:•                for (IVdmSourceUnit sourceUnit : this.vdmSourceUnits)
58:                 {
59:•                        if (sourceUnit instanceof VdmSourceUnitWorkingCopy)
60:                         {
61:                                 ((VdmSourceUnitWorkingCopy) sourceUnit).commit();
62:                         }
63:                 }
64:                 sourceModel.setTypeCheckedStatus(isTypeCorrect());
65:                 synchronized (sourceModel)
66:                 {
67:                         sourceModel.workingCopyNotCommitedCount--;
68:                 }
69:         }
70:         
71:         public synchronized void discard()
72:         {
73:                 this.discarded = true;
74:                 synchronized (sourceModel)
75:                 {
76:                         sourceModel.workingCopyNotCommitedCount--;
77:                 }
78:         }
79:
80:         @Override
81:         protected void fireModelCheckedEvent()
82:         {
83:                 // do not fire from working copy
84:         }
85: }