Package: LatexUtilsBase

LatexUtilsBase

nameinstructionbranchcomplexitylinemethod
LatexUtilsBase()
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%
getDocument(IVdmProject)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getFileChildern(File)
M: 42 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
getFileName(File)
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
hasGenerateMainDocument(IVdmProject)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
insertCoverageTable(IVdmProject)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
markCoverage(IVdmProject)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
modelOnly(IVdmProject)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
parseClasses(IVdmProject)
M: 40 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
parseModules(IVdmProject)
M: 40 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * org.overture.ide.plugins.latex
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.plugins.latex.utility;
23:
24: import java.io.File;
25: import java.util.List;
26: import java.util.Vector;
27:
28: import org.eclipse.core.runtime.CoreException;
29: import org.overture.ast.lex.Dialect;
30: import org.overture.ast.util.definitions.ClassList;
31: import org.overture.ast.util.modules.ModuleList;
32: import org.overture.ide.core.resources.IVdmProject;
33: import org.overture.ide.core.resources.IVdmSourceUnit;
34: import org.overture.ide.plugins.latex.ILatexConstants;
35: import org.overture.ide.plugins.latex.LatexPlugin;
36: import org.overture.parser.lex.LexTokenReader;
37: import org.overture.parser.syntax.ClassReader;
38: import org.overture.parser.syntax.ModuleReader;
39:
40: public class LatexUtilsBase
41: {
42:
43:         public boolean hasGenerateMainDocument(IVdmProject project)
44:                         throws CoreException
45:         {
46:                 return project.getOptions().getGroup(LatexPlugin.PLUGIN_ID, true).getAttribute(ILatexConstants.LATEX_GENERATE_MAIN_DOCUMENT, true);
47:         }
48:
49:         public String getDocument(IVdmProject project) throws CoreException
50:         {
51:                 return project.getOptions().getGroup(LatexPlugin.PLUGIN_ID, true).getAttribute(ILatexConstants.LATEX_MAIN_DOCUMENT, "");
52:         }
53:
54:         public boolean insertCoverageTable(IVdmProject project)
55:                         throws CoreException
56:         {
57:                 return project.getOptions().getGroup(LatexPlugin.PLUGIN_ID, true).getAttribute(ILatexConstants.LATEX_INCLUDE_COVERAGETABLE, ILatexConstants.LATEX_INCLUDE_COVERAGETABLE_DEFAULT);
58:         }
59:
60:         public boolean markCoverage(IVdmProject project) throws CoreException
61:         {
62:                 return project.getOptions().getGroup(LatexPlugin.PLUGIN_ID, true).getAttribute(ILatexConstants.LATEX_MARK_COVERAGE, ILatexConstants.LATEX_MARK_COVERAGE_DEFAULT);
63:         }
64:
65:         public boolean modelOnly(IVdmProject project) throws CoreException
66:         {
67:                 return project.getOptions().getGroup(LatexPlugin.PLUGIN_ID, true).getAttribute(ILatexConstants.LATEX_MODEL_ONLY, true);
68:         }
69:
70:         public static String getFileName(File file)
71:         {
72:                 int index = file.getName().lastIndexOf('.');
73:                 return file.getName().substring(0, index);
74:
75:         }
76:
77:         static List<File> getFileChildern(File file)
78:         {
79:                 List<File> list = new Vector<File>();
80:
81:•                if (file.isFile())
82:                 {
83:                         list.add(file);
84:                         return list;
85:                 }
86:
87:•                if (file != null && file.listFiles() != null)
88:                 {
89:•                        for (File file2 : file.listFiles())
90:                         {
91:                                 list.addAll(getFileChildern(file2));
92:                         }
93:                 }
94:
95:                 return list;
96:
97:         }
98:
99:         ClassList parseClasses(final IVdmProject project) throws CoreException
100:         {
101:                 ClassReader reader;
102:                 ClassList classes = new ClassList();
103:•                for (IVdmSourceUnit source : project.getSpecFiles())
104:                 {
105:                         String charset = source.getFile().getCharset();
106:
107:                         LexTokenReader ltr = new LexTokenReader(source.getSystemFile(), Dialect.VDM_RT, charset);
108:                         reader = new ClassReader(ltr);
109:
110:                         classes.addAll(reader.readClasses());
111:                 }
112:                 return classes;
113:         }
114:
115:         ModuleList parseModules(final IVdmProject project) throws CoreException
116:         {
117:                 ModuleReader reader;
118:                 ModuleList modules = new ModuleList();
119:•                for (IVdmSourceUnit source : project.getSpecFiles())
120:                 {
121:                         String charset = source.getFile().getCharset();
122:
123:                         LexTokenReader ltr = new LexTokenReader(source.getSystemFile(), Dialect.VDM_SL, charset);
124:                         reader = new ModuleReader(ltr);
125:
126:                         modules.addAll(reader.readModules());
127:
128:                 }
129:                 return modules;
130:         }
131:
132: }