1 19 20 package org.netbeans.editor.ext.java; 21 22 import java.util.HashMap ; 23 import org.netbeans.editor.BaseTokenCategory; 24 import org.netbeans.editor.BaseTokenID; 25 import org.netbeans.editor.TokenID; 26 import org.netbeans.editor.BaseImageTokenID; 27 import org.netbeans.editor.TokenContext; 28 import org.netbeans.editor.TokenContextPath; 29 import org.netbeans.editor.Utilities; 30 31 38 39 public class JavaTokenContext extends TokenContext { 40 41 public static final int KEYWORDS_ID = 1; 43 public static final int OPERATORS_ID = KEYWORDS_ID + 1; 44 public static final int NUMERIC_LITERALS_ID = OPERATORS_ID + 1; 45 public static final int ERRORS_ID = NUMERIC_LITERALS_ID + 1; 46 47 public static final int WHITESPACE_ID = ERRORS_ID + 1; 49 public static final int IDENTIFIER_ID = WHITESPACE_ID + 1; 50 public static final int LINE_COMMENT_ID = IDENTIFIER_ID + 1; 51 public static final int BLOCK_COMMENT_ID = LINE_COMMENT_ID + 1; 52 public static final int CHAR_LITERAL_ID = BLOCK_COMMENT_ID + 1; 53 public static final int STRING_LITERAL_ID = CHAR_LITERAL_ID + 1; 54 public static final int INT_LITERAL_ID = STRING_LITERAL_ID + 1; 55 public static final int LONG_LITERAL_ID = INT_LITERAL_ID + 1; 56 public static final int HEX_LITERAL_ID = LONG_LITERAL_ID + 1; 57 public static final int OCTAL_LITERAL_ID = HEX_LITERAL_ID + 1; 58 public static final int FLOAT_LITERAL_ID = OCTAL_LITERAL_ID + 1; 59 public static final int DOUBLE_LITERAL_ID = FLOAT_LITERAL_ID + 1; 60 61 public static final int EQ_ID = DOUBLE_LITERAL_ID + 1; public static final int LT_ID = EQ_ID + 1; public static final int GT_ID = LT_ID + 1; public static final int LSHIFT_ID = GT_ID + 1; public static final int RSSHIFT_ID = LSHIFT_ID + 1; public static final int RUSHIFT_ID = RSSHIFT_ID + 1; public static final int PLUS_ID = RUSHIFT_ID + 1; public static final int MINUS_ID = PLUS_ID + 1; public static final int MUL_ID = MINUS_ID + 1; public static final int DIV_ID = MUL_ID + 1; public static final int AND_ID = DIV_ID + 1; public static final int OR_ID = AND_ID + 1; public static final int XOR_ID = OR_ID + 1; public static final int MOD_ID = XOR_ID + 1; public static final int NOT_ID = MOD_ID + 1; public static final int NEG_ID = NOT_ID + 1; public static final int EQ_EQ_ID = NEG_ID + 1; public static final int LT_EQ_ID = EQ_EQ_ID + 1; public static final int GT_EQ_ID = LT_EQ_ID + 1; public static final int LSHIFT_EQ_ID = GT_EQ_ID + 1; public static final int RSSHIFT_EQ_ID = LSHIFT_EQ_ID + 1; public static final int RUSHIFT_EQ_ID = RSSHIFT_EQ_ID + 1; public static final int PLUS_EQ_ID = RUSHIFT_EQ_ID + 1; public static final int MINUS_EQ_ID = PLUS_EQ_ID + 1; public static final int MUL_EQ_ID = MINUS_EQ_ID + 1; public static final int DIV_EQ_ID = MUL_EQ_ID + 1; public static final int AND_EQ_ID = DIV_EQ_ID + 1; public static final int OR_EQ_ID = AND_EQ_ID + 1; public static final int XOR_EQ_ID = OR_EQ_ID + 1; public static final int MOD_EQ_ID = XOR_EQ_ID + 1; public static final int NOT_EQ_ID = MOD_EQ_ID + 1; public static final int DOT_ID = NOT_EQ_ID + 1; public static final int COMMA_ID = DOT_ID + 1; public static final int COLON_ID = COMMA_ID + 1; public static final int SEMICOLON_ID = COLON_ID + 1; public static final int QUESTION_ID = SEMICOLON_ID + 1; public static final int LPAREN_ID = QUESTION_ID + 1; public static final int RPAREN_ID = LPAREN_ID + 1; public static final int LBRACKET_ID = RPAREN_ID + 1; public static final int RBRACKET_ID = LBRACKET_ID + 1; public static final int LBRACE_ID = RBRACKET_ID + 1; public static final int RBRACE_ID = LBRACE_ID + 1; public static final int PLUS_PLUS_ID = RBRACE_ID + 1; public static final int MINUS_MINUS_ID = PLUS_PLUS_ID + 1; public static final int AND_AND_ID = MINUS_MINUS_ID + 1; public static final int OR_OR_ID = AND_AND_ID + 1; 109 public static final int BOOLEAN_ID = OR_OR_ID + 1; 111 public static final int BYTE_ID = BOOLEAN_ID + 1; 112 public static final int CHAR_ID = BYTE_ID + 1; 113 public static final int DOUBLE_ID = CHAR_ID + 1; 114 public static final int FLOAT_ID = DOUBLE_ID + 1; 115 public static final int INT_ID = FLOAT_ID + 1; 116 public static final int LONG_ID = INT_ID + 1; 117 public static final int SHORT_ID = LONG_ID + 1; 118 119 public static final int VOID_ID = SHORT_ID + 1; 121 122 public static final int ABSTRACT_ID = VOID_ID + 1; 124 public static final int ASSERT_ID = ABSTRACT_ID + 1; 125 public static final int BREAK_ID = ASSERT_ID + 1; 126 public static final int CASE_ID = BREAK_ID + 1; 127 public static final int CATCH_ID = CASE_ID + 1; 128 public static final int CLASS_ID = CATCH_ID + 1; 129 public static final int CONST_ID = CLASS_ID + 1; 130 public static final int CONTINUE_ID = CONST_ID + 1; 131 public static final int DEFAULT_ID = CONTINUE_ID + 1; 132 public static final int DO_ID = DEFAULT_ID + 1; 133 public static final int ELSE_ID = DO_ID + 1; 134 public static final int ENUM_ID = ELSE_ID + 1; 135 public static final int EXTENDS_ID = ENUM_ID+ 1; 136 public static final int FALSE_ID = EXTENDS_ID + 1; 137 public static final int FINAL_ID = FALSE_ID + 1; 138 public static final int FINALLY_ID = FINAL_ID + 1; 139 public static final int FOR_ID = FINALLY_ID + 1; 140 public static final int GOTO_ID = FOR_ID + 1; 141 public static final int IF_ID = GOTO_ID + 1; 142 public static final int IMPLEMENTS_ID = IF_ID + 1; 143 public static final int IMPORT_ID = IMPLEMENTS_ID + 1; 144 public static final int INSTANCEOF_ID = IMPORT_ID + 1; 145 public static final int INTERFACE_ID = INSTANCEOF_ID + 1; 146 public static final int NATIVE_ID = INTERFACE_ID + 1; 147 public static final int NEW_ID = NATIVE_ID + 1; 148 public static final int NULL_ID = NEW_ID + 1; 149 public static final int PACKAGE_ID = NULL_ID + 1; 150 public static final int PRIVATE_ID = PACKAGE_ID + 1; 151 public static final int PROTECTED_ID = PRIVATE_ID + 1; 152 public static final int PUBLIC_ID = PROTECTED_ID + 1; 153 public static final int RETURN_ID = PUBLIC_ID + 1; 154 public static final int STATIC_ID = RETURN_ID + 1; 155 public static final int STRICTFP_ID = STATIC_ID + 1; 156 public static final int SUPER_ID = STRICTFP_ID + 1; 157 public static final int SWITCH_ID = SUPER_ID + 1; 158 public static final int SYNCHRONIZED_ID = SWITCH_ID + 1; 159 public static final int THIS_ID = SYNCHRONIZED_ID + 1; 160 public static final int THROW_ID = THIS_ID + 1; 161 public static final int THROWS_ID = THROW_ID + 1; 162 public static final int TRANSIENT_ID = THROWS_ID + 1; 163 public static final int TRUE_ID = TRANSIENT_ID + 1; 164 public static final int TRY_ID = TRUE_ID + 1; 165 public static final int VOLATILE_ID = TRY_ID + 1; 166 public static final int WHILE_ID = VOLATILE_ID + 1; 167 168 public static final int INCOMPLETE_STRING_LITERAL_ID = WHILE_ID + 1; 170 public static final int INCOMPLETE_CHAR_LITERAL_ID = INCOMPLETE_STRING_LITERAL_ID + 1; 171 public static final int INCOMPLETE_HEX_LITERAL_ID = INCOMPLETE_CHAR_LITERAL_ID + 1; 172 public static final int INVALID_CHAR_ID = INCOMPLETE_HEX_LITERAL_ID + 1; 173 public static final int INVALID_OPERATOR_ID = INVALID_CHAR_ID + 1; 174 public static final int INVALID_OCTAL_LITERAL_ID = INVALID_OPERATOR_ID + 1; 175 public static final int INVALID_COMMENT_END_ID = INVALID_OCTAL_LITERAL_ID + 1; 176 177 public static final int ANNOTATION_ID = INVALID_COMMENT_END_ID + 1; 180 181 public static final int ELLIPSIS_ID = ANNOTATION_ID + 1; 183 184 185 187 public static final BaseTokenCategory KEYWORDS 188 = new BaseTokenCategory("keywords", KEYWORDS_ID); 190 191 public static final BaseTokenCategory OPERATORS 192 = new BaseTokenCategory("operators", OPERATORS_ID); 194 195 public static final BaseTokenCategory NUMERIC_LITERALS 196 = new BaseTokenCategory("numeric-literals", NUMERIC_LITERALS_ID); 198 201 public static final BaseTokenCategory ERRORS 202 = new BaseTokenCategory("errors", ERRORS_ID); 204 205 public static final BaseTokenID WHITESPACE 207 = new BaseTokenID("whitespace", WHITESPACE_ID); 209 public static final BaseTokenID IDENTIFIER 210 = new BaseTokenID("identifier", IDENTIFIER_ID); 212 213 public static final BaseTokenID LINE_COMMENT 214 = new BaseTokenID("line-comment", LINE_COMMENT_ID); 216 217 public static final BaseTokenID BLOCK_COMMENT 218 = new BaseTokenID("block-comment", BLOCK_COMMENT_ID); 220 221 public static final BaseTokenID CHAR_LITERAL 222 = new BaseTokenID("char-literal", CHAR_LITERAL_ID); 224 225 public static final BaseTokenID STRING_LITERAL 226 = new BaseTokenID("string-literal", STRING_LITERAL_ID); 228 229 public static final BaseTokenID INT_LITERAL 230 = new BaseTokenID("int-literal", INT_LITERAL_ID, NUMERIC_LITERALS); 232 233 public static final BaseTokenID LONG_LITERAL 234 = new BaseTokenID("long-literal", LONG_LITERAL_ID, NUMERIC_LITERALS); 236 237 public static final BaseTokenID HEX_LITERAL 238 = new BaseTokenID("hex-literal", HEX_LITERAL_ID, NUMERIC_LITERALS); 240 241 public static final BaseTokenID OCTAL_LITERAL 242 = new BaseTokenID("octal-literal", OCTAL_LITERAL_ID, NUMERIC_LITERALS); 244 245 public static final BaseTokenID FLOAT_LITERAL 246 = new BaseTokenID("float-literal", FLOAT_LITERAL_ID, NUMERIC_LITERALS); 248 249 public static final BaseTokenID DOUBLE_LITERAL 250 = new BaseTokenID("double-literal", DOUBLE_LITERAL_ID, NUMERIC_LITERALS); 252 public static final BaseImageTokenID EQ 254 = new BaseImageTokenID("eq", EQ_ID, OPERATORS, "="); 256 public static final BaseImageTokenID LT 257 = new BaseImageTokenID("lt", LT_ID, OPERATORS, "<"); 259 public static final BaseImageTokenID GT 260 = new BaseImageTokenID("gt", GT_ID, OPERATORS, ">"); 262 public static final BaseImageTokenID LSHIFT 263 = new BaseImageTokenID("lshift", LSHIFT_ID, OPERATORS, "<<"); 265 public static final BaseImageTokenID RSSHIFT 266 = new BaseImageTokenID("rsshift", RSSHIFT_ID, OPERATORS, ">>"); 268 public static final BaseImageTokenID RUSHIFT 269 = new BaseImageTokenID("rushift", RUSHIFT_ID, OPERATORS, ">>>"); 271 public static final BaseImageTokenID PLUS 272 = new BaseImageTokenID("plus", PLUS_ID, OPERATORS, "+"); 274 public static final BaseImageTokenID MINUS 275 = new BaseImageTokenID("minus", MINUS_ID, OPERATORS, "-"); 277 public static final BaseImageTokenID MUL 278 = new BaseImageTokenID("mul", MUL_ID, OPERATORS, "*"); 280 public static final BaseImageTokenID DIV 281 = new BaseImageTokenID("div", DIV_ID, OPERATORS, "/"); 283 public static final BaseImageTokenID AND 284 = new BaseImageTokenID("and", AND_ID, OPERATORS, "&"); 286 public static final BaseImageTokenID OR 287 = new BaseImageTokenID("or", OR_ID, OPERATORS, "|"); 289 public static final BaseImageTokenID XOR 290 = new BaseImageTokenID("xor", XOR_ID, OPERATORS, "^"); 292 public static final BaseImageTokenID MOD 293 = new BaseImageTokenID("mod", MOD_ID, OPERATORS, "%"); 295 public static final BaseImageTokenID NOT 296 = new BaseImageTokenID("not", NOT_ID, OPERATORS, "!"); 298 public static final BaseImageTokenID NEG 299 = new BaseImageTokenID("neg", NEG_ID, OPERATORS, "~"); 301 302 public static final BaseImageTokenID EQ_EQ 303 = new BaseImageTokenID("eq-eq", EQ_EQ_ID, OPERATORS, "=="); 305 public static final BaseImageTokenID LT_EQ 306 = new BaseImageTokenID("le", LT_EQ_ID, OPERATORS, "<="); 308 public static final BaseImageTokenID GT_EQ 309 = new BaseImageTokenID("ge", GT_EQ_ID, OPERATORS, ">="); 311 public static final BaseImageTokenID LSHIFT_EQ 312 = new BaseImageTokenID("lshift-eq", LSHIFT_EQ_ID, OPERATORS, "<<="); 314 public static final BaseImageTokenID RSSHIFT_EQ 315 = new BaseImageTokenID("rsshift-eq", RSSHIFT_EQ_ID, OPERATORS, ">>="); 317 public static final BaseImageTokenID RUSHIFT_EQ 318 = new BaseImageTokenID("rushift-eq", RUSHIFT_EQ_ID, OPERATORS, ">>>="); 320 public static final BaseImageTokenID PLUS_EQ 321 = new BaseImageTokenID("plus-eq", PLUS_EQ_ID, OPERATORS, "+="); 323 public static final BaseImageTokenID MINUS_EQ 324 = new BaseImageTokenID("minus-eq", MINUS_EQ_ID, OPERATORS, "-="); 326 public static final BaseImageTokenID MUL_EQ 327 = new BaseImageTokenID("mul-eq", MUL_EQ_ID, OPERATORS, "*="); 329 public static final BaseImageTokenID DIV_EQ 330 = new BaseImageTokenID("div-eq", DIV_EQ_ID, OPERATORS, "/="); 332 public static final BaseImageTokenID AND_EQ 333 = new BaseImageTokenID("and-eq", AND_EQ_ID, OPERATORS, "&="); 335 public static final BaseImageTokenID OR_EQ 336 = new BaseImageTokenID("or-eq", OR_EQ_ID, OPERATORS, "|="); 338 public static final BaseImageTokenID XOR_EQ 339 = new BaseImageTokenID("xor-eq", XOR_EQ_ID, OPERATORS, "^="); 341 public static final BaseImageTokenID MOD_EQ 342 = new BaseImageTokenID("mod-eq", MOD_EQ_ID, OPERATORS, "%="); 344 public static final BaseImageTokenID NOT_EQ 345 = new BaseImageTokenID("not-eq", NOT_EQ_ID, OPERATORS, "!="); 347 348 public static final BaseImageTokenID DOT 349 = new BaseImageTokenID("dot", DOT_ID, OPERATORS, "."); 351 public static final BaseImageTokenID COMMA 352 = new BaseImageTokenID("comma", COMMA_ID, OPERATORS, ","); 354 public static final BaseImageTokenID COLON 355 = new BaseImageTokenID("colon", COLON_ID, OPERATORS, ":"); 357 public static final BaseImageTokenID SEMICOLON 358 = new BaseImageTokenID("semicolon", SEMICOLON_ID, OPERATORS, ";"); 360 public static final BaseImageTokenID QUESTION 361 = new BaseImageTokenID("question", QUESTION_ID, OPERATORS, "?"); 363 public static final BaseImageTokenID LPAREN 364 = new BaseImageTokenID("lparen", LPAREN_ID, OPERATORS, "("); 366 public static final BaseImageTokenID RPAREN 367 = new BaseImageTokenID("rparen", RPAREN_ID, OPERATORS, ")"); 369 public static final BaseImageTokenID LBRACKET 370 = new BaseImageTokenID("lbracket", LBRACKET_ID, OPERATORS, "["); 372 public static final BaseImageTokenID RBRACKET 373 = new BaseImageTokenID("rbracket", RBRACKET_ID, OPERATORS, "]"); 375 public static final BaseImageTokenID LBRACE 376 = new BaseImageTokenID("lbrace", LBRACE_ID, OPERATORS, "{"); 378 public static final BaseImageTokenID RBRACE 379 = new BaseImageTokenID("rbrace", RBRACE_ID, OPERATORS, "}"); 381 public static final BaseImageTokenID PLUS_PLUS 382 = new BaseImageTokenID("plus-plus", PLUS_PLUS_ID, OPERATORS, "++"); 384 public static final BaseImageTokenID MINUS_MINUS 385 = new BaseImageTokenID("minus-minus", MINUS_MINUS_ID, OPERATORS, "--"); 387 public static final BaseImageTokenID AND_AND 388 = new BaseImageTokenID("and-and", AND_AND_ID, OPERATORS, "&&"); 390 public static final BaseImageTokenID OR_OR 391 = new BaseImageTokenID("or-or", OR_OR_ID, OPERATORS, "||"); 393 394 public static final BaseImageTokenID BOOLEAN 396 = new BaseImageTokenID("boolean", BOOLEAN_ID, KEYWORDS); 398 public static final BaseImageTokenID BYTE 399 = new BaseImageTokenID("byte", BYTE_ID, KEYWORDS); 401 public static final BaseImageTokenID CHAR 402 = new BaseImageTokenID("char", CHAR_ID, KEYWORDS); 404 public static final BaseImageTokenID DOUBLE 405 = new BaseImageTokenID("double", DOUBLE_ID, KEYWORDS); 407 public static final BaseImageTokenID FLOAT 408 = new BaseImageTokenID("float", FLOAT_ID, KEYWORDS); 410 public static final BaseImageTokenID INT 411 = new BaseImageTokenID("int", INT_ID, KEYWORDS); 413 public static final BaseImageTokenID LONG 414 = new BaseImageTokenID("long", LONG_ID, KEYWORDS); 416 public static final BaseImageTokenID SHORT 417 = new BaseImageTokenID("short", SHORT_ID, KEYWORDS); 419 public static final BaseImageTokenID VOID 421 = new BaseImageTokenID("void", VOID_ID, KEYWORDS); 423 public static final BaseImageTokenID ABSTRACT 425 = new BaseImageTokenID("abstract", ABSTRACT_ID, KEYWORDS); 427 public static final BaseImageTokenID ASSERT 428 = new BaseImageTokenID("assert", ASSERT_ID, KEYWORDS); 430 public static final BaseImageTokenID BREAK 431 = new BaseImageTokenID("break", BREAK_ID, KEYWORDS); 433 public static final BaseImageTokenID CASE 434 = new BaseImageTokenID("case", CASE_ID, KEYWORDS); 436 public static final BaseImageTokenID CATCH 437 = new BaseImageTokenID("catch", CATCH_ID, KEYWORDS); 439 public static final BaseImageTokenID CLASS 440 = new BaseImageTokenID("class", CLASS_ID, KEYWORDS); 442 public static final BaseImageTokenID CONST 443 = new BaseImageTokenID("const", CONST_ID, KEYWORDS); 445 public static final BaseImageTokenID CONTINUE 446 = new BaseImageTokenID("continue", CONTINUE_ID, KEYWORDS); 448 public static final BaseImageTokenID DEFAULT 449 = new BaseImageTokenID("default", DEFAULT_ID, KEYWORDS); 451 public static final BaseImageTokenID DO 452 = new BaseImageTokenID("do", DO_ID, KEYWORDS); 454 public static final BaseImageTokenID ELSE 455 = new BaseImageTokenID("else", ELSE_ID, KEYWORDS); 457 public static final BaseImageTokenID ENUM 458 = new BaseImageTokenID("enum", ENUM_ID, KEYWORDS); 460 public static final BaseImageTokenID EXTENDS 461 = new BaseImageTokenID("extends", EXTENDS_ID, KEYWORDS); 463 public static final BaseImageTokenID FALSE 464 = new BaseImageTokenID("false", FALSE_ID, KEYWORDS); 466 public static final BaseImageTokenID FINAL 467 = new BaseImageTokenID("final", FINAL_ID, KEYWORDS); 469 public static final BaseImageTokenID FINALLY 470 = new BaseImageTokenID("finally", FINALLY_ID, KEYWORDS); 472 public static final BaseImageTokenID FOR 473 = new BaseImageTokenID("for", FOR_ID, KEYWORDS); 475 public static final BaseImageTokenID GOTO 476 = new BaseImageTokenID("goto", GOTO_ID, KEYWORDS); 478 public static final BaseImageTokenID IF 479 = new BaseImageTokenID("if", IF_ID, KEYWORDS); 481 public static final BaseImageTokenID IMPLEMENTS 482 = new BaseImageTokenID("implements", IMPLEMENTS_ID, KEYWORDS); 484 public static final BaseImageTokenID IMPORT 485 = new BaseImageTokenID("import", IMPORT_ID, KEYWORDS); 487 public static final BaseImageTokenID INSTANCEOF 488 = new BaseImageTokenID("instanceof", INSTANCEOF_ID, KEYWORDS); 490 public static final BaseImageTokenID INTERFACE 491 = new BaseImageTokenID("interface", INTERFACE_ID, KEYWORDS); 493 public static final BaseImageTokenID NATIVE 494 = new BaseImageTokenID("native", NATIVE_ID, KEYWORDS); 496 public static final BaseImageTokenID NEW 497 = new BaseImageTokenID("new", NEW_ID, KEYWORDS); 499 public static final BaseImageTokenID NULL 500 = new BaseImageTokenID("null", NULL_ID, KEYWORDS); 502 public static final BaseImageTokenID PACKAGE 503 = new BaseImageTokenID("package", PACKAGE_ID, KEYWORDS); 505 public static final BaseImageTokenID PRIVATE 506 = new BaseImageTokenID("private", PRIVATE_ID, KEYWORDS); 508 public static final BaseImageTokenID PROTECTED 509 = new BaseImageTokenID("protected", PROTECTED_ID, KEYWORDS); 511 public static final BaseImageTokenID PUBLIC 512 = new BaseImageTokenID("public", PUBLIC_ID, KEYWORDS); 514 public static final BaseImageTokenID RETURN 515 = new BaseImageTokenID("return", RETURN_ID, KEYWORDS); 517 public static final BaseImageTokenID STATIC 518 = new BaseImageTokenID("static", STATIC_ID, KEYWORDS); 520 public static final BaseImageTokenID STRICTFP 521 = new BaseImageTokenID("strictfp", STRICTFP_ID, KEYWORDS); 523 public static final BaseImageTokenID SUPER 524 = new BaseImageTokenID("super", SUPER_ID, KEYWORDS); 526 public static final BaseImageTokenID SWITCH 527 = new BaseImageTokenID("switch", SWITCH_ID, KEYWORDS); 529 public static final BaseImageTokenID SYNCHRONIZED 530 = new BaseImageTokenID("synchronized", SYNCHRONIZED_ID, KEYWORDS); 532 public static final BaseImageTokenID THIS 533 = new BaseImageTokenID("this", THIS_ID, KEYWORDS); 535 public static final BaseImageTokenID THROW 536 = new BaseImageTokenID("throw", THROW_ID, KEYWORDS); 538 public static final BaseImageTokenID THROWS 539 = new BaseImageTokenID("throws", THROWS_ID, KEYWORDS); 541 public static final BaseImageTokenID TRANSIENT 542 = new BaseImageTokenID("transient", TRANSIENT_ID, KEYWORDS); 544 public static final BaseImageTokenID TRUE 545 = new BaseImageTokenID("true", TRUE_ID, KEYWORDS); 547 public static final BaseImageTokenID TRY 548 = new BaseImageTokenID("try", TRY_ID, KEYWORDS); 550 public static final BaseImageTokenID VOLATILE 551 = new BaseImageTokenID("volatile", VOLATILE_ID, KEYWORDS); 553 public static final BaseImageTokenID WHILE 554 = new BaseImageTokenID("while", WHILE_ID, KEYWORDS); 556 public static final BaseTokenID INCOMPLETE_STRING_LITERAL 558 = new BaseTokenID("incomplete-string-literal", INCOMPLETE_STRING_LITERAL_ID, ERRORS); 560 public static final BaseTokenID INCOMPLETE_CHAR_LITERAL 561 = new BaseTokenID("incomplete-char-literal", INCOMPLETE_CHAR_LITERAL_ID, ERRORS); 563 public static final BaseTokenID INCOMPLETE_HEX_LITERAL 564 = new BaseTokenID("incomplete-hex-literal", INCOMPLETE_HEX_LITERAL_ID, ERRORS); 566 public static final BaseTokenID INVALID_CHAR 567 = new BaseTokenID("invalid-char", INVALID_CHAR_ID, ERRORS); 569 public static final BaseTokenID INVALID_OPERATOR 570 = new BaseTokenID("invalid-operator", INVALID_OPERATOR_ID, ERRORS); 572 public static final BaseTokenID INVALID_OCTAL_LITERAL 573 = new BaseTokenID("invalid-octal-literal", INVALID_OCTAL_LITERAL_ID, ERRORS); 575 public static final BaseTokenID INVALID_COMMENT_END 576 = new BaseTokenID("invalid-comment-end", INVALID_COMMENT_END_ID, ERRORS); 578 579 public static final BaseTokenID ANNOTATION 582 = new BaseTokenID("annotation", ANNOTATION_ID); 584 public static final BaseImageTokenID ELLIPSIS 586 = new BaseImageTokenID("ellipsis", ELLIPSIS_ID, OPERATORS, "..."); 588 public static final JavaTokenContext context = new JavaTokenContext(); 590 591 public static final TokenContextPath contextPath = context.getContextPath(); 592 593 private static final HashMap str2kwd = new HashMap (); 594 595 static { 596 BaseImageTokenID[] kwds = new BaseImageTokenID[] { 597 ABSTRACT, ASSERT, BREAK, CASE, CATCH, CLASS, CONST, CONTINUE, DEFAULT, DO, 598 ELSE, ENUM, EXTENDS, FALSE, FINAL, FINALLY, FOR, GOTO, IF, IMPLEMENTS, 599 IMPORT, INSTANCEOF, INTERFACE, NATIVE, NEW, NULL, PACKAGE, PRIVATE, 600 PROTECTED, PUBLIC, RETURN, STATIC, STRICTFP, SUPER, SWITCH, SYNCHRONIZED, THIS, 601 THROW, THROWS, TRANSIENT, TRUE, TRY, VOLATILE, WHILE, 602 BOOLEAN, BYTE, CHAR, DOUBLE, FLOAT, INT, LONG, SHORT, VOID 603 }; 604 605 for (int i = kwds.length - 1; i >= 0; i--) { 606 str2kwd.put(kwds[i].getImage(), kwds[i]); 607 } 608 } 609 610 613 public static boolean isType(TokenID keywordTokenID) { 614 int numID = (keywordTokenID != null) ? keywordTokenID.getNumericID() : -1; 615 return (numID >= BOOLEAN_ID && numID < VOID_ID); 616 } 617 618 619 public static boolean isType(String s) { 620 return isType((TokenID)str2kwd.get(s)); 621 } 622 623 626 public static boolean isTypeOrVoid(TokenID keywordTokenID) { 627 int numID = (keywordTokenID != null) ? keywordTokenID.getNumericID() : -1; 628 return (numID >= BOOLEAN_ID && numID <= VOID_ID); 629 } 630 631 632 public static boolean isTypeOrVoid(String s) { 633 return isTypeOrVoid((TokenID)str2kwd.get(s)); 634 } 635 636 637 public static TokenID getKeyword(String s) { 638 return (TokenID)str2kwd.get(s); 639 } 640 641 private JavaTokenContext() { 642 super("java-"); 644 try { 645 addDeclaredTokenIDs(); 646 } catch (Exception e) { 647 Utilities.annotateLoggable(e); 648 } 649 650 } 651 652 } 653 | Popular Tags |