1 | /* | |
2 | * This file is part of a syntax highlighting package | |
3 | * Copyright (C) 1999, 2000 Stephen Ostermiller | |
4 | * http://ostermiller.org/contact.pl?regarding=Syntax+Highlighting | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * See COPYING.TXT for details. | |
17 | */ | |
18 | package com.jsql.view.swing.sql.lexer.syntax; | |
19 | ||
20 | /** | |
21 | * A JavaScriptToken is a token that is returned by a lexer that is lexing a javascript | |
22 | * source file. It has several attributes describing the token: | |
23 | * The type of token, the text of the token, the line number on which it | |
24 | * occurred, the number of characters into the input at which it started, and | |
25 | * similarly, the number of characters into the input at which it ended. <br> | |
26 | * The tokens should comply with the | |
27 | * <A Href="http://developer.netscape.com/docs/manuals/communicator/jsref/index.htm"> | |
28 | * Java Script Reference</A>. | |
29 | */ | |
30 | public class JavaScriptToken extends Token { | |
31 | public final static int RESERVED_WORD_ABSTRACT = 0x101; | |
32 | public final static int RESERVED_WORD_BOOLEAN = 0x102; | |
33 | public final static int RESERVED_WORD_BREAK = 0x103; | |
34 | public final static int RESERVED_WORD_BYTE = 0x104; | |
35 | public final static int RESERVED_WORD_CASE = 0x105; | |
36 | public final static int RESERVED_WORD_CATCH = 0x106; | |
37 | public final static int RESERVED_WORD_CHAR = 0x107; | |
38 | public final static int RESERVED_WORD_CLASS = 0x108; | |
39 | public final static int RESERVED_WORD_CONST = 0x109; | |
40 | public final static int RESERVED_WORD_CONTINUE = 0x10A; | |
41 | public final static int RESERVED_WORD_DEFAULT = 0x10B; | |
42 | public final static int RESERVED_WORD_DO = 0x10C; | |
43 | public final static int RESERVED_WORD_DOUBLE = 0x10D; | |
44 | public final static int RESERVED_WORD_ELSE = 0x10E; | |
45 | public final static int RESERVED_WORD_EXTENDS = 0x10F; | |
46 | public final static int RESERVED_WORD_FALSE = 0x110; | |
47 | public final static int RESERVED_WORD_FINAL = 0x111; | |
48 | public final static int RESERVED_WORD_FINALLY = 0x112; | |
49 | public final static int RESERVED_WORD_FLOAT = 0x113; | |
50 | public final static int RESERVED_WORD_FOR = 0x114; | |
51 | public final static int RESERVED_WORD_FUNCTION = 0x115; | |
52 | public final static int RESERVED_WORD_GOTO = 0x116; | |
53 | public final static int RESERVED_WORD_IF = 0x117; | |
54 | public final static int RESERVED_WORD_IMPLEMENTS = 0x118; | |
55 | public final static int RESERVED_WORD_IMPORT = 0x119; | |
56 | public final static int RESERVED_WORD_IN = 0x11A; | |
57 | public final static int RESERVED_WORD_INSTANCEOF = 0x11B; | |
58 | public final static int RESERVED_WORD_INT = 0x11C; | |
59 | public final static int RESERVED_WORD_INTERFACE = 0x11D; | |
60 | public final static int RESERVED_WORD_LONG = 0x11E; | |
61 | public final static int RESERVED_WORD_NATIVE = 0x11F; | |
62 | public final static int RESERVED_WORD_NEW = 0x120; | |
63 | public final static int RESERVED_WORD_NULL = 0x121; | |
64 | public final static int RESERVED_WORD_PACKAGE = 0x122; | |
65 | public final static int RESERVED_WORD_PRIVATE = 0x123; | |
66 | public final static int RESERVED_WORD_PROTECTED = 0x124; | |
67 | public final static int RESERVED_WORD_PUBLIC = 0x125; | |
68 | public final static int RESERVED_WORD_RETURN = 0x126; | |
69 | public final static int RESERVED_WORD_SHORT = 0x127; | |
70 | public final static int RESERVED_WORD_STATIC = 0x128; | |
71 | public final static int RESERVED_WORD_SUPER = 0x129; | |
72 | public final static int RESERVED_WORD_SWITCH = 0x12A; | |
73 | public final static int RESERVED_WORD_SYNCHRONIZED = 0x12B; | |
74 | public final static int RESERVED_WORD_THIS = 0x12C; | |
75 | public final static int RESERVED_WORD_THROW = 0x12D; | |
76 | public final static int RESERVED_WORD_THROWS = 0x12E; | |
77 | public final static int RESERVED_WORD_TRANSIENT = 0x12F; | |
78 | public final static int RESERVED_WORD_TRUE = 0x130; | |
79 | public final static int RESERVED_WORD_TRY = 0x131; | |
80 | public final static int RESERVED_WORD_VAR = 0x132; | |
81 | public final static int RESERVED_WORD_VOID = 0x133; | |
82 | public final static int RESERVED_WORD_WHILE = 0x134; | |
83 | public final static int RESERVED_WORD_WITH = 0x135; | |
84 | | |
85 | public final static int IDENTIFIER = 0x200; | |
86 | ||
87 | public final static int LITERAL_BOOLEAN = 0x300; | |
88 | public final static int LITERAL_INTEGER_DECIMAL = 0x310; | |
89 | public final static int LITERAL_INTEGER_OCTAL = 0x311; | |
90 | public final static int LITERAL_INTEGER_HEXIDECIMAL = 0x312; | |
91 | public final static int LITERAL_LONG_DECIMAL = 0x320; | |
92 | public final static int LITERAL_LONG_OCTAL = 0x321; | |
93 | public final static int LITERAL_LONG_HEXIDECIMAL = 0x322; | |
94 | public final static int LITERAL_FLOATING_POINT = 0x330; | |
95 | public final static int LITERAL_DOUBLE = 0x340; | |
96 | public final static int LITERAL_CHARACTER = 0x350; | |
97 | public final static int LITERAL_STRING = 0x360; | |
98 | public final static int LITERAL_NULL = 0x370; | |
99 | ||
100 | public final static int SEPARATOR_LPAREN = 0x400; | |
101 | public final static int SEPARATOR_RPAREN = 0x401; | |
102 | public final static int SEPARATOR_LBRACE = 0x410; | |
103 | public final static int SEPARATOR_RBRACE = 0x411; | |
104 | public final static int SEPARATOR_LBRACKET = 0x420; | |
105 | public final static int SEPARATOR_RBRACKET = 0x421; | |
106 | public final static int SEPARATOR_SEMICOLON = 0x430; | |
107 | public final static int SEPARATOR_COMMA = 0x440; | |
108 | public final static int SEPARATOR_PERIOD = 0x450; | |
109 | ||
110 | public final static int OPERATOR_GREATER_THAN = 0x500; | |
111 | public final static int OPERATOR_LESS_THAN = 0x501; | |
112 | public final static int OPERATOR_LESS_THAN_OR_EQUAL = 0x502; | |
113 | public final static int OPERATOR_GREATER_THAN_OR_EQUAL = 0x503; | |
114 | public final static int OPERATOR_EQUAL = 0x504; | |
115 | public final static int OPERATOR_NOT_EQUAL = 0x505; | |
116 | public final static int OPERATOR_LOGICAL_NOT = 0x510; | |
117 | public final static int OPERATOR_LOGICAL_AND = 0x511; | |
118 | public final static int OPERATOR_LOGICAL_OR = 0x512; | |
119 | public final static int OPERATOR_ADD = 0x520; | |
120 | public final static int OPERATOR_SUBTRACT = 0x521; | |
121 | public final static int OPERATOR_MULTIPLY = 0x522; | |
122 | public final static int OPERATOR_DIVIDE = 0x523; | |
123 | public final static int OPERATOR_MOD = 0x524; | |
124 | public final static int OPERATOR_BITWISE_COMPLIMENT = 0x530; | |
125 | public final static int OPERATOR_BITWISE_AND = 0x531; | |
126 | public final static int OPERATOR_BITWISE_OR = 0x532; | |
127 | public final static int OPERATOR_BITWISE_XOR = 0x533; | |
128 | public final static int OPERATOR_SHIFT_LEFT = 0x540; | |
129 | public final static int OPERATOR_SHIFT_RIGHT = 0x541; | |
130 | public final static int OPERATOR_SHIFT_RIGHT_UNSIGNED = 0x542; | |
131 | public final static int OPERATOR_ASSIGN = 0x550; | |
132 | public final static int OPERATOR_ADD_ASSIGN = 0x560; | |
133 | public final static int OPERATOR_SUBTRACT_ASSIGN = 0x561; | |
134 | public final static int OPERATOR_MULTIPLY_ASSIGN = 0x562; | |
135 | public final static int OPERATOR_DIVIDE_ASSIGN = 0x563; | |
136 | public final static int OPERATOR_MOD_ASSIGN = 0x564; | |
137 | public final static int OPERATOR_BITWISE_AND_ASSIGN = 0x571; | |
138 | public final static int OPERATOR_BITWISE_OR_ASSIGN = 0x572; | |
139 | public final static int OPERATOR_BITWISE_XOR_ASSIGN = 0x573; | |
140 | public final static int OPERATOR_SHIFT_LEFT_ASSIGN = 0x580; | |
141 | public final static int OPERATOR_SHIFT_RIGHT_ASSIGN = 0x581; | |
142 | public final static int OPERATOR_SHIFT_RIGHT_UNSIGNED_ASSIGN = 0x582; | |
143 | public final static int OPERATOR_INCREMENT = 0x590; | |
144 | public final static int OPERATOR_DECREMENT = 0x591; | |
145 | public final static int OPERATOR_QUESTION = 0x5A0; | |
146 | public final static int OPERATOR_COLON = 0x5A1; | |
147 | | |
148 | public final static int COMMENT_TRADITIONAL = 0xD00; | |
149 | public final static int COMMENT_END_OF_LINE = 0xD10; | |
150 | public final static int COMMENT_DOCUMENTATION = 0xD20; | |
151 | ||
152 | public final static int WHITE_SPACE = 0xE00; | |
153 | ||
154 | public final static int ERROR_IDENTIFIER = 0xF00; | |
155 | public final static int ERROR_UNCLOSED_STRING = 0xF10; | |
156 | public final static int ERROR_MALFORMED_STRING = 0xF11; | |
157 | public final static int ERROR_MALFORMED_UNCLOSED_STRING = 0xF12; | |
158 | public final static int ERROR_UNCLOSED_CHARACTER = 0xF20; | |
159 | public final static int ERROR_MALFORMED_CHARACTER = 0xF21; | |
160 | public final static int ERROR_MALFORMED_UNCLOSED_CHARACTER = 0xF22; | |
161 | public final static int ERROR_INTEGER_DECIMIAL_SIZE = 0xF30; | |
162 | public final static int ERROR_INTEGER_OCTAL_SIZE = 0xF31; | |
163 | public final static int ERROR_INTEGER_HEXIDECIMAL_SIZE = 0xF32; | |
164 | public final static int ERROR_LONG_DECIMIAL_SIZE = 0xF33; | |
165 | public final static int ERROR_LONG_OCTAL_SIZE = 0xF34; | |
166 | public final static int ERROR_LONG_HEXIDECIMAL_SIZE = 0xF35; | |
167 | public final static int ERROR_FLOAT_SIZE = 0xF36; | |
168 | public final static int ERROR_DOUBLE_SIZE = 0xF37; | |
169 | public final static int ERROR_FLOAT = 0xF38; | |
170 | public final static int ERROR_UNCLOSED_COMMENT = 0xF40; | |
171 | | |
172 | private final int ID; | |
173 | private final String contents; | |
174 | private final int lineNumber; | |
175 | private final int charBegin; | |
176 | private final int charEnd; | |
177 | private final int state; | |
178 | ||
179 | /** | |
180 | * Create a new token. | |
181 | * The constructor is typically called by the lexer | |
182 | * | |
183 | * @param ID the id number of the token | |
184 | * @param contents A string representing the text of the token | |
185 | * @param lineNumber the line number of the input on which this token started | |
186 | * @param charBegin the offset into the input in characters at which this token started | |
187 | * @param charEnd the offset into the input in characters at which this token ended | |
188 | */ | |
189 | public JavaScriptToken(int ID, String contents, int lineNumber, int charBegin, int charEnd) { | |
190 | this (ID, contents, lineNumber, charBegin, charEnd, Token.UNDEFINED_STATE); | |
191 | } | |
192 | ||
193 | /** | |
194 | * Create a new token. | |
195 | * The constructor is typically called by the lexer | |
196 | * | |
197 | * @param ID the id number of the token | |
198 | * @param contents A string representing the text of the token | |
199 | * @param lineNumber the line number of the input on which this token started | |
200 | * @param charBegin the offset into the input in characters at which this token started | |
201 | * @param charEnd the offset into the input in characters at which this token ended | |
202 | * @param state the state the tokenizer is in after returning this token. | |
203 | */ | |
204 | public JavaScriptToken(int ID, String contents, int lineNumber, int charBegin, int charEnd, int state) { | |
205 | this.ID = ID; | |
206 | this.contents = contents; | |
207 | this.lineNumber = lineNumber; | |
208 | this.charBegin = charBegin; | |
209 | this.charEnd = charEnd; | |
210 | this.state = state; | |
211 | } | |
212 | ||
213 | /** | |
214 | * Get an integer representing the state the tokenizer is in after | |
215 | * returning this token. | |
216 | * Those who are interested in incremental tokenizing for performance | |
217 | * reasons will want to use this method to figure out where the tokenizer | |
218 | * may be restarted. The tokenizer starts in Token.INITIAL_STATE, so | |
219 | * any time that it reports that it has returned to this state, the | |
220 | * tokenizer may be restarted from there. | |
221 | */ | |
222 | @Override | |
223 | public int getState() { | |
224 |
1
1. getState : replaced int return with 0 for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::getState → NO_COVERAGE |
return this.state; |
225 | } | |
226 | /** | |
227 | * get the ID number of this token | |
228 | * | |
229 | * @return the id number of the token | |
230 | */ | |
231 | @Override | |
232 | public int getID() { | |
233 |
1
1. getID : replaced int return with 0 for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::getID → NO_COVERAGE |
return this.ID; |
234 | } | |
235 | ||
236 | /** | |
237 | * get the contents of this token | |
238 | * | |
239 | * @return A string representing the text of the token | |
240 | */ | |
241 | @Override | |
242 | public String getContents() { | |
243 |
1
1. getContents : replaced return value with "" for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::getContents → NO_COVERAGE |
return (new String(this.contents)); |
244 | } | |
245 | ||
246 | /** | |
247 | * get the line number of the input on which this token started | |
248 | * | |
249 | * @return the line number of the input on which this token started | |
250 | */ | |
251 | @Override | |
252 | public int getLineNumber() { | |
253 |
1
1. getLineNumber : replaced int return with 0 for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::getLineNumber → NO_COVERAGE |
return this.lineNumber; |
254 | } | |
255 | ||
256 | /** | |
257 | * get the offset into the input in characters at which this token started | |
258 | * | |
259 | * @return the offset into the input in characters at which this token started | |
260 | */ | |
261 | @Override | |
262 | public int getCharBegin() { | |
263 |
1
1. getCharBegin : replaced int return with 0 for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::getCharBegin → NO_COVERAGE |
return this.charBegin; |
264 | } | |
265 | ||
266 | /** | |
267 | * get the offset into the input in characters at which this token ended | |
268 | * | |
269 | * @return the offset into the input in characters at which this token ended | |
270 | */ | |
271 | @Override | |
272 | public int getCharEnd() { | |
273 |
1
1. getCharEnd : replaced int return with 0 for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::getCharEnd → NO_COVERAGE |
return this.charEnd; |
274 | } | |
275 | ||
276 | /** | |
277 | * Checks this token to see if it is a reserved word. | |
278 | * Reserved words are explained in <A Href=http://java.sun.com/docs/books/jls/html/>Java | |
279 | * Language Specification</A>. | |
280 | * | |
281 | * @return true if this token is a reserved word, false otherwise | |
282 | */ | |
283 | public boolean isReservedWord() { | |
284 |
3
1. isReservedWord : replaced boolean return with true for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::isReservedWord → NO_COVERAGE 2. isReservedWord : Replaced Shift Right with Shift Left → NO_COVERAGE 3. isReservedWord : negated conditional → NO_COVERAGE |
return((this.ID >> 8) == 0x1); |
285 | } | |
286 | ||
287 | /** | |
288 | * Checks this token to see if it is an identifier. | |
289 | * Identifiers are explained in <A Href=http://java.sun.com/docs/books/jls/html/>Java | |
290 | * Language Specification</A>. | |
291 | * | |
292 | * @return true if this token is an identifier, false otherwise | |
293 | */ | |
294 | public boolean isIdentifier() { | |
295 |
3
1. isIdentifier : Replaced Shift Right with Shift Left → NO_COVERAGE 2. isIdentifier : negated conditional → NO_COVERAGE 3. isIdentifier : replaced boolean return with true for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::isIdentifier → NO_COVERAGE |
return((this.ID >> 8) == 0x2); |
296 | } | |
297 | ||
298 | /** | |
299 | * Checks this token to see if it is a literal. | |
300 | * Literals are explained in <A Href=http://java.sun.com/docs/books/jls/html/>Java | |
301 | * Language Specification</A>. | |
302 | * | |
303 | * @return true if this token is a literal, false otherwise | |
304 | */ | |
305 | public boolean isLiteral() { | |
306 |
3
1. isLiteral : replaced boolean return with true for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::isLiteral → NO_COVERAGE 2. isLiteral : Replaced Shift Right with Shift Left → NO_COVERAGE 3. isLiteral : negated conditional → NO_COVERAGE |
return((this.ID >> 8) == 0x3); |
307 | } | |
308 | | |
309 | /** | |
310 | * Checks this token to see if it is a Separator. | |
311 | * Separators are explained in <A Href=http://java.sun.com/docs/books/jls/html/>Java | |
312 | * Language Specification</A>. | |
313 | * | |
314 | * @return true if this token is a Separator, false otherwise | |
315 | */ | |
316 | public boolean isSeparator() { | |
317 |
3
1. isSeparator : replaced boolean return with true for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::isSeparator → NO_COVERAGE 2. isSeparator : negated conditional → NO_COVERAGE 3. isSeparator : Replaced Shift Right with Shift Left → NO_COVERAGE |
return((this.ID >> 8) == 0x4); |
318 | } | |
319 | ||
320 | /** | |
321 | * Checks this token to see if it is a Operator. | |
322 | * Operators are explained in <A Href=http://java.sun.com/docs/books/jls/html/>Java | |
323 | * Language Specification</A>. | |
324 | * | |
325 | * @return true if this token is a Operator, false otherwise | |
326 | */ | |
327 | public boolean isOperator() { | |
328 |
3
1. isOperator : negated conditional → NO_COVERAGE 2. isOperator : Replaced Shift Right with Shift Left → NO_COVERAGE 3. isOperator : replaced boolean return with true for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::isOperator → NO_COVERAGE |
return((this.ID >> 8) == 0x5); |
329 | } | |
330 | ||
331 | /** | |
332 | * Checks this token to see if it is a comment. | |
333 | * | |
334 | * @return true if this token is a comment, false otherwise | |
335 | */ | |
336 | @Override | |
337 | public boolean isComment() { | |
338 |
3
1. isComment : negated conditional → NO_COVERAGE 2. isComment : Replaced Shift Right with Shift Left → NO_COVERAGE 3. isComment : replaced boolean return with true for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::isComment → NO_COVERAGE |
return((this.ID >> 8) == 0xD); |
339 | } | |
340 | ||
341 | /** | |
342 | * Checks this token to see if it is White Space. | |
343 | * Usually tabs, line breaks, form feed, spaces, etc. | |
344 | * | |
345 | * @return true if this token is White Space, false otherwise | |
346 | */ | |
347 | @Override | |
348 | public boolean isWhiteSpace() { | |
349 |
3
1. isWhiteSpace : replaced boolean return with true for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::isWhiteSpace → NO_COVERAGE 2. isWhiteSpace : negated conditional → NO_COVERAGE 3. isWhiteSpace : Replaced Shift Right with Shift Left → NO_COVERAGE |
return((this.ID >> 8) == 0xE); |
350 | } | |
351 | ||
352 | /** | |
353 | * Checks this token to see if it is an Error. | |
354 | * Unfinished comments, numbers that are too big, unclosed strings, etc. | |
355 | * | |
356 | * @return true if this token is an Error, false otherwise | |
357 | */ | |
358 | @Override | |
359 | public boolean isError() { | |
360 |
3
1. isError : replaced boolean return with true for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::isError → NO_COVERAGE 2. isError : Replaced Shift Right with Shift Left → NO_COVERAGE 3. isError : negated conditional → NO_COVERAGE |
return((this.ID >> 8) == 0xF); |
361 | } | |
362 | ||
363 | /** | |
364 | * A description of this token. The description should | |
365 | * be appropriate for syntax highlighting. For example | |
366 | * "comment" is returned for a comment. | |
367 | * | |
368 | * @return a description of this token. | |
369 | */ | |
370 | @Override | |
371 | public String getDescription() { | |
372 |
1
1. getDescription : negated conditional → NO_COVERAGE |
if (this.isReservedWord()) { |
373 |
1
1. getDescription : replaced return value with "" for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::getDescription → NO_COVERAGE |
return("reservedWord"); |
374 |
1
1. getDescription : negated conditional → NO_COVERAGE |
} else if (this.isIdentifier()) { |
375 |
1
1. getDescription : replaced return value with "" for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::getDescription → NO_COVERAGE |
return("identifier"); |
376 |
1
1. getDescription : negated conditional → NO_COVERAGE |
} else if (this.isLiteral()) { |
377 |
1
1. getDescription : replaced return value with "" for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::getDescription → NO_COVERAGE |
return("literal"); |
378 |
1
1. getDescription : negated conditional → NO_COVERAGE |
} else if (this.isSeparator()) { |
379 |
1
1. getDescription : replaced return value with "" for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::getDescription → NO_COVERAGE |
return("separator"); |
380 |
1
1. getDescription : negated conditional → NO_COVERAGE |
} else if (this.isOperator()) { |
381 |
1
1. getDescription : replaced return value with "" for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::getDescription → NO_COVERAGE |
return("operator"); |
382 |
1
1. getDescription : negated conditional → NO_COVERAGE |
} else if (this.isComment()) { |
383 |
1
1. getDescription : replaced return value with "" for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::getDescription → NO_COVERAGE |
return("comment"); |
384 |
1
1. getDescription : negated conditional → NO_COVERAGE |
} else if (this.isWhiteSpace()) { |
385 |
1
1. getDescription : replaced return value with "" for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::getDescription → NO_COVERAGE |
return("whitespace"); |
386 |
1
1. getDescription : negated conditional → NO_COVERAGE |
} else if (this.isError()) { |
387 |
1
1. getDescription : replaced return value with "" for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::getDescription → NO_COVERAGE |
return("error"); |
388 | } else { | |
389 |
1
1. getDescription : replaced return value with "" for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::getDescription → NO_COVERAGE |
return("unknown"); |
390 | } | |
391 | } | |
392 | ||
393 | /** | |
394 | * get a String that explains the error, if this token is an error. | |
395 | * | |
396 | * @return a String that explains the error, if this token is an error, null otherwise. | |
397 | */ | |
398 | @Override | |
399 | public String errorString() { | |
400 | String s; | |
401 |
1
1. errorString : negated conditional → NO_COVERAGE |
if (this.isError()) { |
402 | s = "Error on line " + this.lineNumber + ": "; | |
403 | switch (this.ID) { | |
404 | case ERROR_IDENTIFIER: | |
405 | s += "Unrecognized Identifier: " + this.contents; | |
406 | break; | |
407 | case ERROR_UNCLOSED_STRING: | |
408 | s += "'\"' expected after " + this.contents; | |
409 | break; | |
410 | case ERROR_MALFORMED_STRING: | |
411 | case ERROR_MALFORMED_UNCLOSED_STRING: | |
412 | case ERROR_MALFORMED_CHARACTER: | |
413 | case ERROR_MALFORMED_UNCLOSED_CHARACTER: | |
414 | case ERROR_INTEGER_DECIMIAL_SIZE: | |
415 | case ERROR_INTEGER_OCTAL_SIZE: | |
416 | case ERROR_FLOAT: | |
417 | s += "Illegal character in " + this.contents; | |
418 | break; | |
419 | case ERROR_UNCLOSED_CHARACTER: | |
420 | s += "\"'\" expected after " + this.contents; | |
421 | break; | |
422 | case ERROR_INTEGER_HEXIDECIMAL_SIZE: | |
423 | case ERROR_LONG_DECIMIAL_SIZE: | |
424 | case ERROR_LONG_OCTAL_SIZE: | |
425 | case ERROR_LONG_HEXIDECIMAL_SIZE: | |
426 | case ERROR_FLOAT_SIZE: | |
427 | case ERROR_DOUBLE_SIZE: | |
428 | s += "Literal out of bounds: " + this.contents; | |
429 | break; | |
430 | case ERROR_UNCLOSED_COMMENT: | |
431 | s += "*/ expected after " + this.contents; | |
432 | break; | |
433 | } | |
434 | } else { | |
435 | s = null; | |
436 | } | |
437 |
1
1. errorString : replaced return value with "" for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::errorString → NO_COVERAGE |
return (s); |
438 | } | |
439 | ||
440 | /** | |
441 | * get a representation of this token as a human-readable string. | |
442 | * The format of this string is subject to change and should only be used | |
443 | * for debugging purposes. | |
444 | * | |
445 | * @return a string representation of this token | |
446 | */ | |
447 | @Override | |
448 | public String toString() { | |
449 |
1
1. toString : replaced return value with "" for com/jsql/view/swing/sql/lexer/syntax/JavaScriptToken::toString → NO_COVERAGE |
return "Token #" + Integer.toHexString(this.ID) + ": " + this.getDescription() + " Line " + |
450 | this.lineNumber + " from " +this.charBegin + " to " + this.charEnd + " : " + this.contents; | |
451 | } | |
452 | } | |
Mutations | ||
224 |
1.1 |
|
233 |
1.1 |
|
243 |
1.1 |
|
253 |
1.1 |
|
263 |
1.1 |
|
273 |
1.1 |
|
284 |
1.1 2.2 3.3 |
|
295 |
1.1 2.2 3.3 |
|
306 |
1.1 2.2 3.3 |
|
317 |
1.1 2.2 3.3 |
|
328 |
1.1 2.2 3.3 |
|
338 |
1.1 2.2 3.3 |
|
349 |
1.1 2.2 3.3 |
|
360 |
1.1 2.2 3.3 |
|
372 |
1.1 |
|
373 |
1.1 |
|
374 |
1.1 |
|
375 |
1.1 |
|
376 |
1.1 |
|
377 |
1.1 |
|
378 |
1.1 |
|
379 |
1.1 |
|
380 |
1.1 |
|
381 |
1.1 |
|
382 |
1.1 |
|
383 |
1.1 |
|
384 |
1.1 |
|
385 |
1.1 |
|
386 |
1.1 |
|
387 |
1.1 |
|
389 |
1.1 |
|
401 |
1.1 |
|
437 |
1.1 |
|
449 |
1.1 |