Package: CombinedDefaultModule

CombinedDefaultModule

nameinstructionbranchcomplexitylinemethod
CombinedDefaultModule(Set)
M: 0 C: 56
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
getDefs()
M: 0 C: 23
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
getFiles()
M: 23 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getModules()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * #%~
3: * The Overture Abstract Syntax Tree
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.ast.util.modules;
23:
24: import java.util.HashSet;
25: import java.util.LinkedList;
26: import java.util.List;
27: import java.util.Set;
28: import java.util.Vector;
29:
30: import org.overture.ast.definitions.PDefinition;
31: import org.overture.ast.lex.LexIdentifierToken;
32: import org.overture.ast.lex.LexLocation;
33: import org.overture.ast.modules.AModuleModules;
34: import org.overture.ast.util.ClonableFile;
35:
36: /**
37: * This is a module used to handle flat specifications in VDM-SL This module is an encapsulation of a number of flat
38: * parsed modules The name of this module is {@code DEFAULT} and it overrides the {@code getDefs} and {@code getFiles}
39: * methods of a normal module such that it returns the union of all contained modules.
40: *
41: * @author kela
42: */
43: public class CombinedDefaultModule extends AModuleModules
44: {
45:         /**
46:          *
47:          */
48:         private static final long serialVersionUID = 1L;
49:         final Set<AModuleModules> modules = new HashSet<AModuleModules>();
50:
51:         @SuppressWarnings("deprecation")
52:         public CombinedDefaultModule(Set<AModuleModules> modules)
53:         {
54:                 super(null, null, null, new Vector<PDefinition>(), new Vector<ClonableFile>(), true, false, null, null);
55:                 this.modules.addAll(modules);
56:
57:•                if (getDefs().isEmpty())
58:                 {
59:                         setName(new LexIdentifierToken("DEFAULT", false, new LexLocation()));
60:                 } else
61:                 {
62:                         setName(new LexIdentifierToken("DEFAULT", false, getDefs().get(0).getLocation()));
63:                 }
64:         }
65:
66:         @Override
67:         public LinkedList<PDefinition> getDefs()
68:         {
69:                 LinkedList<PDefinition> definitions = new LinkedList<PDefinition>();
70:
71:•                for (AModuleModules m : modules)
72:                 {
73:                         definitions.addAll(m.getDefs());
74:                 }
75:
76:                 return definitions;
77:         }
78:
79:         @Override
80:         public List<? extends ClonableFile> getFiles()
81:         {
82:                 LinkedList<ClonableFile> allFiles = new LinkedList<ClonableFile>();
83:
84:•                for (AModuleModules m : modules)
85:                 {
86:                         allFiles.addAll(m.getFiles());
87:                 }
88:
89:                 return allFiles;
90:         }
91:
92:         /**
93:          * This method returns all the modules encapsulated within this container
94:          *
95:          * @return a set of contained modules
96:          */
97:         public Set<AModuleModules> getModules()
98:         {
99:                 return this.modules;
100:         }
101: }