1 package com.puppycrawl.tools.checkstyle.api; 20 21 import java.util.Map ; 22 import java.util.HashMap ; 23 import java.util.ResourceBundle ; 24 import java.lang.reflect.Field ; 25 26 import com.puppycrawl.tools.checkstyle.grammars.GeneratedJavaTokenTypes; 27 28 39 public final class TokenTypes 40 { 41 43 private TokenTypes() 44 { 45 } 46 48 51 52 54 56 58 61 72 public static final int EOF = GeneratedJavaTokenTypes.EOF; 73 94 public static final int MODIFIERS = GeneratedJavaTokenTypes.MODIFIERS; 95 115 public static final int OBJBLOCK = GeneratedJavaTokenTypes.OBJBLOCK; 116 133 public static final int SLIST = GeneratedJavaTokenTypes.SLIST; 134 200 public static final int CTOR_DEF = GeneratedJavaTokenTypes.CTOR_DEF; 201 264 public static final int METHOD_DEF = GeneratedJavaTokenTypes.METHOD_DEF; 265 275 public static final int VARIABLE_DEF = 276 GeneratedJavaTokenTypes.VARIABLE_DEF; 277 278 289 public static final int INSTANCE_INIT = 290 GeneratedJavaTokenTypes.INSTANCE_INIT; 291 292 304 public static final int STATIC_INIT = 305 GeneratedJavaTokenTypes.STATIC_INIT; 306 307 331 public static final int TYPE = GeneratedJavaTokenTypes.TYPE; 332 371 public static final int CLASS_DEF = GeneratedJavaTokenTypes.CLASS_DEF; 372 409 public static final int INTERFACE_DEF = 410 GeneratedJavaTokenTypes.INTERFACE_DEF; 411 412 456 public static final int PACKAGE_DEF = GeneratedJavaTokenTypes.PACKAGE_DEF; 457 495 public static final int ARRAY_DECLARATOR = 496 GeneratedJavaTokenTypes.ARRAY_DECLARATOR; 497 498 526 public static final int EXTENDS_CLAUSE = 527 GeneratedJavaTokenTypes.EXTENDS_CLAUSE; 528 529 554 public static final int IMPLEMENTS_CLAUSE = 555 GeneratedJavaTokenTypes.IMPLEMENTS_CLAUSE; 556 557 591 public static final int PARAMETERS = GeneratedJavaTokenTypes.PARAMETERS; 592 603 public static final int PARAMETER_DEF = 604 GeneratedJavaTokenTypes.PARAMETER_DEF; 605 606 626 public static final int LABELED_STAT = 627 GeneratedJavaTokenTypes.LABELED_STAT; 628 629 661 public static final int TYPECAST = GeneratedJavaTokenTypes.TYPECAST; 662 687 public static final int INDEX_OP = GeneratedJavaTokenTypes.INDEX_OP; 688 697 public static final int POST_INC = GeneratedJavaTokenTypes.POST_INC; 698 707 public static final int POST_DEC = GeneratedJavaTokenTypes.POST_DEC; 708 735 public static final int METHOD_CALL = GeneratedJavaTokenTypes.METHOD_CALL; 736 792 public static final int EXPR = GeneratedJavaTokenTypes.EXPR; 793 877 public static final int ARRAY_INIT = GeneratedJavaTokenTypes.ARRAY_INIT; 878 913 public static final int IMPORT = GeneratedJavaTokenTypes.IMPORT; 914 922 public static final int UNARY_MINUS = GeneratedJavaTokenTypes.UNARY_MINUS; 923 931 public static final int UNARY_PLUS = GeneratedJavaTokenTypes.UNARY_PLUS; 932 983 public static final int CASE_GROUP = GeneratedJavaTokenTypes.CASE_GROUP; 984 996 public static final int ELIST = GeneratedJavaTokenTypes.ELIST; 997 1007 public static final int FOR_INIT = GeneratedJavaTokenTypes.FOR_INIT; 1008 1016 public static final int FOR_CONDITION = 1017 GeneratedJavaTokenTypes.FOR_CONDITION; 1018 1019 1027 public static final int FOR_ITERATOR = 1028 GeneratedJavaTokenTypes.FOR_ITERATOR; 1029 1030 1041 public static final int EMPTY_STAT = GeneratedJavaTokenTypes.EMPTY_STAT; 1042 1047 public static final int FINAL = GeneratedJavaTokenTypes.FINAL; 1048 1053 public static final int ABSTRACT = GeneratedJavaTokenTypes.ABSTRACT; 1054 1059 public static final int STRICTFP = GeneratedJavaTokenTypes.STRICTFP; 1060 1068 public static final int SUPER_CTOR_CALL = 1069 GeneratedJavaTokenTypes.SUPER_CTOR_CALL; 1070 1071 1097 public static final int CTOR_CALL = GeneratedJavaTokenTypes.CTOR_CALL; 1098 1103 1106 1116 public static final int SEMI = GeneratedJavaTokenTypes.SEMI; 1117 1122 1125 1131 1138 public static final int RBRACK = GeneratedJavaTokenTypes.RBRACK; 1139 1144 public static final int LITERAL_VOID = 1145 GeneratedJavaTokenTypes.LITERAL_void; 1146 1147 1152 public static final int LITERAL_BOOLEAN = 1153 GeneratedJavaTokenTypes.LITERAL_boolean; 1154 1155 1160 public static final int LITERAL_BYTE = 1161 GeneratedJavaTokenTypes.LITERAL_byte; 1162 1163 1168 public static final int LITERAL_CHAR = 1169 GeneratedJavaTokenTypes.LITERAL_char; 1170 1171 1176 public static final int LITERAL_SHORT = 1177 GeneratedJavaTokenTypes.LITERAL_short; 1178 1179 1184 public static final int LITERAL_INT = GeneratedJavaTokenTypes.LITERAL_int; 1185 1190 public static final int LITERAL_FLOAT = 1191 GeneratedJavaTokenTypes.LITERAL_float; 1192 1193 1198 public static final int LITERAL_LONG = 1199 GeneratedJavaTokenTypes.LITERAL_long; 1200 1201 1206 public static final int LITERAL_DOUBLE = 1207 GeneratedJavaTokenTypes.LITERAL_double; 1208 1209 1213 public static final int IDENT = GeneratedJavaTokenTypes.IDENT; 1214 1219 public static final int DOT = GeneratedJavaTokenTypes.DOT; 1220 1232 public static final int STAR = GeneratedJavaTokenTypes.STAR; 1233 1238 public static final int LITERAL_PRIVATE = 1239 GeneratedJavaTokenTypes.LITERAL_private; 1240 1241 1246 public static final int LITERAL_PUBLIC = 1247 GeneratedJavaTokenTypes.LITERAL_public; 1248 1249 1254 public static final int LITERAL_PROTECTED = 1255 GeneratedJavaTokenTypes.LITERAL_protected; 1256 1257 1262 public static final int LITERAL_STATIC = 1263 GeneratedJavaTokenTypes.LITERAL_static; 1264 1265 1270 public static final int LITERAL_TRANSIENT = 1271 GeneratedJavaTokenTypes.LITERAL_transient; 1272 1273 1278 public static final int LITERAL_NATIVE = 1279 GeneratedJavaTokenTypes.LITERAL_native; 1280 1281 1324 public static final int LITERAL_SYNCHRONIZED = 1325 GeneratedJavaTokenTypes.LITERAL_synchronized; 1326 1327 1332 public static final int LITERAL_VOLATILE = 1333 GeneratedJavaTokenTypes.LITERAL_volatile; 1334 1335 1360 public static final int LITERAL_CLASS = 1361 GeneratedJavaTokenTypes.LITERAL_class; 1362 1363 1368 1371 1377 public static final int LITERAL_INTERFACE = 1378 GeneratedJavaTokenTypes.LITERAL_interface; 1379 1380 1387 public static final int LCURLY = GeneratedJavaTokenTypes.LCURLY; 1388 1395 public static final int RCURLY = GeneratedJavaTokenTypes.RCURLY; 1396 1405 public static final int COMMA = GeneratedJavaTokenTypes.COMMA; 1406 1411 1414 1423 public static final int LPAREN = GeneratedJavaTokenTypes.LPAREN; 1424 1435 public static final int RPAREN = GeneratedJavaTokenTypes.RPAREN; 1436 1442 public static final int LITERAL_THIS = 1443 GeneratedJavaTokenTypes.LITERAL_this; 1444 1445 1451 public static final int LITERAL_SUPER = 1452 GeneratedJavaTokenTypes.LITERAL_super; 1453 1454 1462 public static final int ASSIGN = GeneratedJavaTokenTypes.ASSIGN; 1463 1477 public static final int LITERAL_THROWS = 1478 GeneratedJavaTokenTypes.LITERAL_throws; 1479 1480 1488 public static final int COLON = GeneratedJavaTokenTypes.COLON; 1489 1543 public static final int LITERAL_IF = GeneratedJavaTokenTypes.LITERAL_if; 1544 1627 public static final int LITERAL_FOR = GeneratedJavaTokenTypes.LITERAL_for; 1628 1682 public static final int LITERAL_WHILE = 1683 GeneratedJavaTokenTypes.LITERAL_while; 1684 1685 1740 public static final int LITERAL_DO = GeneratedJavaTokenTypes.LITERAL_do; 1741 1745 public static final int DO_WHILE = GeneratedJavaTokenTypes.DO_WHILE; 1746 1754 public static final int LITERAL_BREAK = 1755 GeneratedJavaTokenTypes.LITERAL_break; 1756 1757 1765 public static final int LITERAL_CONTINUE = 1766 GeneratedJavaTokenTypes.LITERAL_continue; 1767 1768 1777 public static final int LITERAL_RETURN = 1778 GeneratedJavaTokenTypes.LITERAL_return; 1779 1780 1884 public static final int LITERAL_SWITCH = 1885 GeneratedJavaTokenTypes.LITERAL_switch; 1886 1887 1897 public static final int LITERAL_THROW = 1898 GeneratedJavaTokenTypes.LITERAL_throw; 1899 1900 1909 public static final int LITERAL_ELSE = 1910 GeneratedJavaTokenTypes.LITERAL_else; 1911 1912 1919 public static final int LITERAL_CASE = 1920 GeneratedJavaTokenTypes.LITERAL_case; 1921 1922 1928 public static final int LITERAL_DEFAULT = 1929 GeneratedJavaTokenTypes.LITERAL_default; 1930 1931 2007 public static final int LITERAL_TRY = GeneratedJavaTokenTypes.LITERAL_try; 2008 2017 public static final int LITERAL_CATCH = 2018 GeneratedJavaTokenTypes.LITERAL_catch; 2019 2020 2026 public static final int LITERAL_FINALLY = 2027 GeneratedJavaTokenTypes.LITERAL_finally; 2028 2029 2037 public static final int PLUS_ASSIGN = GeneratedJavaTokenTypes.PLUS_ASSIGN; 2038 2046 public static final int MINUS_ASSIGN = 2047 GeneratedJavaTokenTypes.MINUS_ASSIGN; 2048 2049 2057 public static final int STAR_ASSIGN = GeneratedJavaTokenTypes.STAR_ASSIGN; 2058 2066 public static final int DIV_ASSIGN = GeneratedJavaTokenTypes.DIV_ASSIGN; 2067 2075 public static final int MOD_ASSIGN = GeneratedJavaTokenTypes.MOD_ASSIGN; 2076 2085 public static final int SR_ASSIGN = GeneratedJavaTokenTypes.SR_ASSIGN; 2086 2095 public static final int BSR_ASSIGN = GeneratedJavaTokenTypes.BSR_ASSIGN; 2096 2104 public static final int SL_ASSIGN = GeneratedJavaTokenTypes.SL_ASSIGN; 2105 2113 public static final int BAND_ASSIGN = GeneratedJavaTokenTypes.BAND_ASSIGN; 2114 2122 public static final int BXOR_ASSIGN = GeneratedJavaTokenTypes.BXOR_ASSIGN; 2123 2131 public static final int BOR_ASSIGN = GeneratedJavaTokenTypes.BOR_ASSIGN; 2132 2164 public static final int QUESTION = GeneratedJavaTokenTypes.QUESTION; 2165 2173 public static final int LOR = GeneratedJavaTokenTypes.LOR; 2174 2182 public static final int LAND = GeneratedJavaTokenTypes.LAND; 2183 2191 public static final int BOR = GeneratedJavaTokenTypes.BOR; 2192 2200 public static final int BXOR = GeneratedJavaTokenTypes.BXOR; 2201 2209 public static final int BAND = GeneratedJavaTokenTypes.BAND; 2210 2215 public static final int NOT_EQUAL = GeneratedJavaTokenTypes.NOT_EQUAL; 2216 2221 public static final int EQUAL = GeneratedJavaTokenTypes.EQUAL; 2222 2227 public static final int LT = GeneratedJavaTokenTypes.LT; 2228 2233 public static final int GT = GeneratedJavaTokenTypes.GT; 2234 2239 public static final int LE = GeneratedJavaTokenTypes.LE; 2240 2245 public static final int GE = GeneratedJavaTokenTypes.GE; 2246 2261 public static final int LITERAL_INSTANCEOF = 2262 GeneratedJavaTokenTypes.LITERAL_instanceof; 2263 2264 2272 public static final int SL = GeneratedJavaTokenTypes.SL; 2273 2281 public static final int SR = GeneratedJavaTokenTypes.SR; 2282 2290 public static final int BSR = GeneratedJavaTokenTypes.BSR; 2291 2299 public static final int PLUS = GeneratedJavaTokenTypes.PLUS; 2300 2308 public static final int MINUS = GeneratedJavaTokenTypes.MINUS; 2309 2317 public static final int DIV = GeneratedJavaTokenTypes.DIV; 2318 2326 public static final int MOD = GeneratedJavaTokenTypes.MOD; 2327 2336 public static final int INC = GeneratedJavaTokenTypes.INC; 2337 2346 public static final int DEC = GeneratedJavaTokenTypes.DEC; 2347 2355 public static final int BNOT = GeneratedJavaTokenTypes.BNOT; 2356 2364 public static final int LNOT = GeneratedJavaTokenTypes.LNOT; 2365 2374 public static final int LITERAL_TRUE = 2375 GeneratedJavaTokenTypes.LITERAL_true; 2376 2377 2386 public static final int LITERAL_FALSE = 2387 GeneratedJavaTokenTypes.LITERAL_false; 2388 2389 2397 public static final int LITERAL_NULL = 2398 GeneratedJavaTokenTypes.LITERAL_null; 2399 2400 2532 public static final int LITERAL_NEW = GeneratedJavaTokenTypes.LITERAL_new; 2533 2543 public static final int NUM_INT = GeneratedJavaTokenTypes.NUM_INT; 2544 2553 public static final int CHAR_LITERAL = 2554 GeneratedJavaTokenTypes.CHAR_LITERAL; 2555 2556 2565 public static final int STRING_LITERAL = 2566 GeneratedJavaTokenTypes.STRING_LITERAL; 2567 2568 2578 public static final int NUM_FLOAT = GeneratedJavaTokenTypes.NUM_FLOAT; 2579 2590 public static final int NUM_LONG = GeneratedJavaTokenTypes.NUM_LONG; 2591 2602 public static final int NUM_DOUBLE = GeneratedJavaTokenTypes.NUM_DOUBLE; 2603 2611 2620 2629 2639 2646 2653 2660 2663 2686 public static final int LITERAL_ASSERT = GeneratedJavaTokenTypes.ASSERT; 2687 2688 2724 public static final int STATIC_IMPORT = 2725 GeneratedJavaTokenTypes.STATIC_IMPORT; 2726 2727 2798 public static final int ENUM_DEF = 2799 GeneratedJavaTokenTypes.ENUM_DEF; 2800 2801 2805 public static final int ENUM = 2806 GeneratedJavaTokenTypes.ENUM; 2807 2808 2865 public static final int ENUM_CONSTANT_DEF = 2866 GeneratedJavaTokenTypes.ENUM_CONSTANT_DEF; 2867 2868 2877 public static final int FOR_EACH_CLAUSE = 2878 GeneratedJavaTokenTypes.FOR_EACH_CLAUSE; 2879 2880 2925 public static final int ANNOTATION_DEF = 2926 GeneratedJavaTokenTypes.ANNOTATION_DEF; 2927 2928 2929 2964 public static final int ANNOTATION_FIELD_DEF = 2965 GeneratedJavaTokenTypes.ANNOTATION_FIELD_DEF; 2966 2967 3003 public static final int ANNOTATIONS = 3004 GeneratedJavaTokenTypes.ANNOTATIONS; 3005 3006 3053 public static final int ANNOTATION = 3054 GeneratedJavaTokenTypes.ANNOTATION; 3055 3056 3066 public static final int ANNOTATION_MEMBER_VALUE_PAIR = 3067 GeneratedJavaTokenTypes.ANNOTATION_MEMBER_VALUE_PAIR; 3068 3069 3100 public static final int ANNOTATION_ARRAY_INIT = 3101 GeneratedJavaTokenTypes.ANNOTATION_ARRAY_INIT; 3102 3103 3154 public static final int TYPE_PARAMETERS = 3155 GeneratedJavaTokenTypes.TYPE_PARAMETERS; 3156 3157 3184 public static final int TYPE_PARAMETER = 3185 GeneratedJavaTokenTypes.TYPE_PARAMETER; 3186 3187 3227 public static final int TYPE_ARGUMENTS = 3228 GeneratedJavaTokenTypes.TYPE_ARGUMENTS; 3229 3230 3258 public static final int TYPE_ARGUMENT = 3259 GeneratedJavaTokenTypes.TYPE_ARGUMENT; 3260 3261 3270 public static final int WILDCARD_TYPE = 3271 GeneratedJavaTokenTypes.WILDCARD_TYPE; 3272 3273 3284 public static final int TYPE_UPPER_BOUNDS = 3285 GeneratedJavaTokenTypes.TYPE_UPPER_BOUNDS; 3286 3287 3296 public static final int TYPE_LOWER_BOUNDS = 3297 GeneratedJavaTokenTypes.TYPE_LOWER_BOUNDS; 3298 3299 3307 public static final int AT = GeneratedJavaTokenTypes.AT; 3308 3309 3316 public static final int ELLIPSIS = GeneratedJavaTokenTypes.ELLIPSIS; 3317 3318 3322 public static final int TYPE_EXTENSION_AND = 3323 GeneratedJavaTokenTypes.TYPE_EXTENSION_AND; 3324 3325 3328 public static final int GENERIC_START = 3329 GeneratedJavaTokenTypes.GENERIC_START; 3330 3331 3334 public static final int GENERIC_END = GeneratedJavaTokenTypes.GENERIC_END; 3335 3336 3340 3341 private static final Map TOKEN_NAME_TO_VALUE = new HashMap (); 3342 3343 private static final String [] TOKEN_VALUE_TO_NAME; 3344 3345 static { 3347 final Field [] fields = TokenTypes.class.getDeclaredFields(); 3348 String [] tempTokenValueToName = new String [0]; 3349 for (int i = 0; i < fields.length; i++) { 3350 final Field f = fields[i]; 3351 3352 if (f.getType() != Integer.TYPE) { 3354 continue; 3355 } 3356 3357 final String name = f.getName(); 3358 try { 3359 final Integer value = new Integer (f.getInt(name)); 3361 TOKEN_NAME_TO_VALUE.put(name, value); 3362 final int tokenValue = value.intValue(); 3363 if (tokenValue > tempTokenValueToName.length - 1) { 3364 final String [] temp = new String [tokenValue + 1]; 3365 System.arraycopy(tempTokenValueToName, 0, 3366 temp, 0, tempTokenValueToName.length); 3367 tempTokenValueToName = temp; 3368 } 3369 tempTokenValueToName[tokenValue] = name; 3370 } 3371 catch (final IllegalArgumentException e) { 3372 e.printStackTrace(); 3373 System.exit(1); 3374 } 3375 catch (final IllegalAccessException e) { 3376 e.printStackTrace(); 3377 System.exit(1); 3378 } 3379 } 3380 TOKEN_VALUE_TO_NAME = tempTokenValueToName; 3381 } 3382 3383 3388 public static String getTokenName(int aID) 3389 { 3390 if (aID > TOKEN_VALUE_TO_NAME.length - 1) { 3391 throw new IllegalArgumentException ("given id " + aID); 3392 } 3393 final String name = TOKEN_VALUE_TO_NAME[aID]; 3394 if (name == null) { 3395 throw new IllegalArgumentException ("given id " + aID); 3396 } 3397 return name; 3398 } 3399 3400 3405 public static int getTokenId(String aName) 3406 { 3407 final Integer id = (Integer ) TOKEN_NAME_TO_VALUE.get(aName); 3408 if (id == null) { 3409 throw new IllegalArgumentException ("given name " + aName); 3410 } 3411 return id.intValue(); 3412 } 3413 3414 3419 public static String getShortDescription(String aName) 3420 { 3421 if (!TOKEN_NAME_TO_VALUE.containsKey(aName)) { 3422 throw new IllegalArgumentException ("given name " + aName); 3423 } 3424 3425 final String tokentypes = 3426 "com.puppycrawl.tools.checkstyle.api.tokentypes"; 3427 final ResourceBundle bundle = ResourceBundle.getBundle(tokentypes); 3428 return bundle.getString(aName); 3429 } 3430} 3431 | Popular Tags |