Package: VdmSourceUnit

VdmSourceUnit

nameinstructionbranchcomplexitylinemethod
VdmSourceUnit(IVdmProject, IFile)
M: 20 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
clean()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
exists()
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%
fireAddedEvent()
M: 13 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
fireChangedEvent()
M: 13 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getAdapter(Class)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getElementType()
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%
getFile()
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%
getParseList()
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%
getProject()
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%
getSystemFile()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getType()
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%
getWorkingCopy()
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
hasParseErrors()
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%
hasParseTree()
M: 8 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
reconcile(List, boolean)
M: 24 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
setType(int)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
toString()
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%

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.resources;
23:
24: import java.io.File;
25: import java.util.List;
26: import java.util.Vector;
27:
28: import org.eclipse.core.resources.IFile;
29: import org.eclipse.core.runtime.Platform;
30: import org.overture.ast.node.INode;
31: import org.overture.ide.core.ElementChangedEvent;
32: import org.overture.ide.core.IVdmElementDelta;
33: import org.overture.ide.core.VdmCore;
34: import org.overture.ide.core.VdmElementDelta;
35:
36: public class VdmSourceUnit implements IVdmSourceUnit
37: {
38:         protected IVdmProject project;
39:         protected IFile file;
40:         protected int type;
41:         protected boolean parseErrors = false;
42:
43:         protected List<INode> parseList = new Vector<INode>();
44:
45:         public VdmSourceUnit(IVdmProject project, IFile file)
46:         {
47:                 this.project = project;
48:                 this.file = file;
49:                 this.type = IVdmSourceUnit.VDM_DEFAULT;
50:
51:         }
52:
53:         public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter)
54:         {
55:                 return Platform.getAdapterManager().getAdapter(this, adapter);
56:         }
57:
58:         public IFile getFile()
59:         {
60:                 return file;
61:         }
62:
63:         public File getSystemFile()
64:         {
65:                 return project.getFile(file);
66:         }
67:
68:         public synchronized void reconcile(List<INode> parseResult,
69:                         boolean parseErrors)
70:         {
71:                 boolean added = this.parseList.isEmpty();
72:                 this.parseList.clear();
73:                 this.parseErrors = parseErrors;
74:•                if (!parseErrors)
75:                 {
76:                         this.parseList.addAll(parseResult);
77:                 }
78:
79:•                if (added)
80:                 {
81:                         fireAddedEvent();
82:                 }
83:                 fireChangedEvent();
84:         }
85:
86:         protected void fireChangedEvent()
87:         {
88:                 VdmCore.getDeltaProcessor().fire(this, new ElementChangedEvent(new VdmElementDelta(this, IVdmElementDelta.CHANGED), ElementChangedEvent.DeltaType.POST_RECONCILE));
89:         }
90:
91:         protected void fireAddedEvent()
92:         {
93:                 VdmCore.getDeltaProcessor().fire(this, new ElementChangedEvent(new VdmElementDelta(this, IVdmElementDelta.ADDED), ElementChangedEvent.DeltaType.POST_RECONCILE));
94:         }
95:
96:         public synchronized List<INode> getParseList()
97:         {
98:                 return this.parseList;
99:         }
100:
101:         public boolean exists()
102:         {
103:                 return this.file.exists();
104:         }
105:
106:         public int getType()
107:         {
108:                 return type;
109:         }
110:
111:         public void setType(int type)
112:         {
113:                 this.type = type;
114:         }
115:
116:         public int getElementType()
117:         {
118:                 return getType();
119:         }
120:
121:         @Override
122:         public String toString()
123:         {
124:                 return file.toString();
125:         }
126:
127:         public synchronized void clean()
128:         {
129:                 this.parseList.clear();
130:
131:         }
132:
133:         public IVdmProject getProject()
134:         {
135:                 return project;
136:         }
137:
138:         public boolean hasParseTree()
139:         {
140:•                return parseList.size() > 0;
141:         }
142:
143:         public boolean hasParseErrors()
144:         {
145:                 return this.parseErrors;
146:         }
147:
148:         public VdmSourceUnitWorkingCopy getWorkingCopy()
149:         {
150:                 return new VdmSourceUnitWorkingCopy(this);
151:         }
152:
153: }