Package: LexIdentifierToken

LexIdentifierToken

nameinstructionbranchcomplexitylinemethod
LexIdentifierToken(String, boolean, ILexLocation)
M: 0 C: 11
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: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
equals(Object)
M: 2 C: 21
91%
M: 2 C: 4
67%
M: 2 C: 2
50%
M: 1 C: 4
80%
M: 0 C: 1
100%
getChildren(Boolean)
M: 27 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
getClassName()
M: 0 C: 35
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
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%
getName()
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%
getOld()
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%
hashCode()
M: 2 C: 9
82%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 1
100%
M: 0 C: 1
100%
isOld()
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%
toString()
M: 2 C: 13
87%
M: 1 C: 1
50%
M: 1 C: 1
50%
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.lex;
23:
24: import java.util.HashMap;
25: import java.util.Map;
26:
27: import org.overture.ast.analysis.AnalysisException;
28: import org.overture.ast.analysis.intf.IAnalysis;
29: import org.overture.ast.analysis.intf.IAnswer;
30: import org.overture.ast.analysis.intf.IQuestion;
31: import org.overture.ast.analysis.intf.IQuestionAnswer;
32: import org.overture.ast.intf.lex.ILexIdentifierToken;
33: import org.overture.ast.intf.lex.ILexLocation;
34: import org.overture.ast.intf.lex.ILexNameToken;
35:
36: public class LexIdentifierToken extends LexToken implements ILexIdentifierToken
37: {
38:         private static final long serialVersionUID = 1L;
39:         public final String name;
40:         public final boolean old;
41:
42:         @Override
43:         public boolean getOld()
44:         {
45:                 return old;
46:         }
47:
48:         public LexIdentifierToken(String name, boolean old, ILexLocation location)
49:         {
50:                 super(location, VDMToken.IDENTIFIER);
51:                 this.name = name;
52:                 this.old = old;
53:         }
54:
55:         public ILexNameToken getClassName()
56:         {
57:                 // We don't know the class name of the name of a class until we've
58:                 // read the name. So create a new location with the right module.
59:
60:                 LexLocation loc = new LexLocation(location.getFile(), name, location.getStartLine(), location.getStartPos(), location.getEndLine(), location.getEndPos(), location.getStartOffset(), location.getEndOffset());
61:
62:                 return new LexNameToken("CLASS", name, loc);
63:         }
64:
65:         @Override
66:         public boolean equals(Object other)
67:         {
68:•                if (other instanceof LexIdentifierToken)
69:                 {
70:                         LexIdentifierToken tother = (LexIdentifierToken) other;
71:•                        return this.name.equals(tother.getName())
72:•                                        && this.old == tother.isOld();
73:                 }
74:
75:                 return false;
76:         }
77:
78:         @Override
79:         public int hashCode()
80:         {
81:•                return name.hashCode() + (old ? 1 : 0);
82:         }
83:
84:         @Override
85:         public String toString()
86:         {
87:•                return name + (old ? "~" : "");
88:         }
89:
90:         public boolean isOld()
91:         {
92:                 return old;
93:         }
94:
95:         public String getName()
96:         {
97:                 return name;
98:         }
99:
100:         public ILexLocation getLocation()
101:         {
102:                 return location;
103:         }
104:
105:         @Override
106:         public LexIdentifierToken clone()
107:         {
108:                 return new LexIdentifierToken(name, old, location);
109:         }
110:
111:         @Override
112:         public void apply(IAnalysis analysis) throws AnalysisException
113:         {
114:                 analysis.caseILexIdentifierToken(this);
115:         }
116:
117:         @Override
118:         public <A> A apply(IAnswer<A> caller) throws AnalysisException
119:         {
120:                 return caller.caseILexIdentifierToken(this);
121:         }
122:
123:         @Override
124:         public <Q> void apply(IQuestion<Q> caller, Q question)
125:                         throws AnalysisException
126:         {
127:                 caller.caseILexIdentifierToken(this, question);
128:         }
129:
130:         @Override
131:         public <Q, A> A apply(IQuestionAnswer<Q, A> caller, Q question)
132:                         throws AnalysisException
133:         {
134:                 return caller.caseILexIdentifierToken(this, question);
135:         }
136:
137:         /**
138:          * Creates a map of all field names and their value
139:          *
140:          * @param includeInheritedFields
141:          * if true all inherited fields are included
142:          * @return a a map of names to values of all fields
143:          */
144:         @Override
145:         public Map<String, Object> getChildren(Boolean includeInheritedFields)
146:         {
147:                 Map<String, Object> fields = new HashMap<String, Object>();
148:•                if (includeInheritedFields)
149:                 {
150:                         fields.putAll(super.getChildren(includeInheritedFields));
151:                 }
152:                 fields.put("name", this.name);
153:                 fields.put("old", this.old);
154:                 return fields;
155:         }
156: }