Package: LexToken

LexToken

nameinstructionbranchcomplexitylinemethod
LexToken(ILexLocation, VDMToken)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
apply(IAnalysis)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
apply(IAnswer)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
apply(IQuestion, Object)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
apply(IQuestionAnswer, Object)
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%
clone()
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
clone(Map)
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getChildren(Boolean)
M: 26 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
getLocation()
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%
getType()
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%
is(VDMToken)
M: 0 C: 8
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isNot(VDMToken)
M: 0 C: 8
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
removeChild(INode)
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%
toString()
M: 0 C: 4
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: *        Copyright (c) 2008 Fujitsu Services Ltd.
4: *
5: *        Author: Nick Battle
6: *
7: *        This file is part of VDMJ.
8: *
9: *        VDMJ is free software: you can redistribute it and/or modify
10: *        it under the terms of the GNU General Public License as published by
11: *        the Free Software Foundation, either version 3 of the License, or
12: *        (at your option) any later version.
13: *
14: *        VDMJ is distributed in the hope that it will be useful,
15: *        but WITHOUT ANY WARRANTY; without even the implied warranty of
16: *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: *        GNU General Public License for more details.
18: *
19: *        You should have received a copy of the GNU General Public License
20: *        along with VDMJ. If not, see <http://www.gnu.org/licenses/>.
21: *
22: ******************************************************************************/
23: package org.overture.ast.lex;
24:
25: import java.io.Serializable;
26: import java.util.HashMap;
27: import java.util.Map;
28:
29: import org.overture.ast.analysis.AnalysisException;
30: import org.overture.ast.analysis.intf.IAnalysis;
31: import org.overture.ast.analysis.intf.IAnswer;
32: import org.overture.ast.analysis.intf.IQuestion;
33: import org.overture.ast.analysis.intf.IQuestionAnswer;
34: import org.overture.ast.intf.lex.ILexLocation;
35: import org.overture.ast.intf.lex.ILexToken;
36: import org.overture.ast.node.INode;
37: import org.overture.ast.node.Node;
38:
39: /**
40: * The parent class for all lexical token types.
41: */
42:
43: public class LexToken extends Node implements ILexToken, Serializable
44: {
45:         private static final long serialVersionUID = 1L;
46:
47:         /** The textual location of the token. */
48:         public final ILexLocation location;
49:         /** The basic type of the token. */
50:         public final VDMToken type;
51:
52:         @Override
53:         public VDMToken getType()
54:         {
55:                 return type;
56:         }
57:
58:         public ILexLocation getLocation()
59:         {
60:                 return location;
61:         }
62:
63:         /**
64:          * Create a token of the given type at the given location.
65:          *
66:          * @param location
67:          * The location of the token.
68:          * @param type
69:          * The basic type of the token.
70:          */
71:
72:         public LexToken(ILexLocation location, VDMToken type)
73:         {
74:                 this.location = location;
75:                 this.type = type;
76:         }
77:
78:         /**
79:          * Test whether this token is a given basic type.
80:          *
81:          * @param ttype
82:          * The type to test.
83:          * @return True if this is of that type.
84:          */
85:
86:         public boolean is(VDMToken ttype)
87:         {
88:•                return this.type == ttype;
89:         }
90:
91:         /**
92:          * Test whether this token is not a given basic type.
93:          *
94:          * @param ttype
95:          * The type to test.
96:          * @return True if this is not of that type.
97:          */
98:
99:         public boolean isNot(VDMToken ttype)
100:         {
101:•                return this.type != ttype;
102:         }
103:
104:         @Override
105:         public String toString()
106:         {
107:                 return type.toString();
108:         }
109:
110:         @Override
111:         public ILexToken clone()
112:         {
113:                 return new LexToken(location, type);
114:         }
115:
116:         @Override
117:         public INode clone(Map<INode, INode> oldToNewMap)
118:         {
119:                 Node newNode = (Node) clone();
120:                 oldToNewMap.put(this, newNode);
121:                 return newNode;
122:         }
123:
124:         @Override
125:         public void apply(IAnalysis analysis) throws AnalysisException
126:         {
127:                 analysis.caseILexToken(this);
128:         }
129:
130:         @Override
131:         public <A> A apply(IAnswer<A> caller) throws AnalysisException
132:         {
133:                 return caller.caseILexToken(this);
134:         }
135:
136:         @Override
137:         public <Q> void apply(IQuestion<Q> caller, Q question)
138:                         throws AnalysisException
139:         {
140:                 caller.caseILexToken(this, question);
141:         }
142:
143:         @Override
144:         public <Q, A> A apply(IQuestionAnswer<Q, A> caller, Q question)
145:                         throws AnalysisException
146:         {
147:                 return caller.caseILexToken(this, question);
148:         }
149:
150:         @Override
151:         public void removeChild(INode child)
152:         {
153:
154:         }
155:
156:         /**
157:          * Creates a map of all field names and their value
158:          *
159:          * @param includeInheritedFields
160:          * if true all inherited fields are included
161:          * @return a a map of names to values of all fields
162:          */
163:         @Override
164:         public Map<String, Object> getChildren(Boolean includeInheritedFields)
165:         {
166:                 Map<String, Object> fields = new HashMap<String, Object>();
167:•                if (includeInheritedFields)
168:                 {
169:                         fields.putAll(super.getChildren(includeInheritedFields));
170:                 }
171:                 fields.put("location", this.location);
172:                 fields.put("type", this.type);
173:                 return fields;
174:         }
175:
176: }