MCPcopy Index your code
hub / github.com/apache/groovy / ofType

Method ofType

src/main/java/org/codehaus/groovy/syntax/Types.java:617–1003  ·  view source on GitHub ↗

Determines if a specific type belongs to a general type category through the type hierarchy. For example, ofType(Types.PLUS, Types.MATH_OPERATOR) returns true because PLUS is classified as a MATH_OPERATOR. @param specific the specific token type to check @param gener

(int specific, int general)

Source from the content-addressed store, hash-verified

615 * @return {@code true} if the specific type is within the general category
616 */
617 public static boolean ofType(int specific, int general) {
618
619 if (general == specific) {
620 return true;
621 }
622
623 switch (general) {
624 case ANY:
625 return true;
626
627 case NOT_EOF:
628 return specific >= UNKNOWN && specific <= SYNTH_VARIABLE_DECLARATION;
629
630 case GENERAL_END_OF_STATEMENT:
631 switch (specific) {
632 case EOF:
633 case NEWLINE:
634 case SEMICOLON:
635 return true;
636 }
637 break;
638
639 case ANY_END_OF_STATEMENT:
640 switch (specific) {
641 case EOF:
642 case NEWLINE:
643 case SEMICOLON:
644 case RIGHT_CURLY_BRACE:
645 return true;
646 }
647 break;
648
649 case ASSIGNMENT_OPERATOR:
650 return specific == EQUAL || (specific >= PLUS_EQUAL && specific <= ELVIS_EQUAL) || (specific >= LOGICAL_OR_EQUAL && specific <= LOGICAL_AND_EQUAL)
651 || (specific >= LEFT_SHIFT_EQUAL && specific <= RIGHT_SHIFT_UNSIGNED_EQUAL)
652 || (specific >= BITWISE_OR_EQUAL && specific <= BITWISE_XOR_EQUAL)
653 || specific == REMAINDER_EQUAL;
654
655 case COMPARISON_OPERATOR:
656 return specific >= COMPARE_NOT_EQUAL && specific <= COMPARE_TO;
657
658 case INSTANCEOF_OPERATOR:
659 return specific == KEYWORD_INSTANCEOF || specific == COMPARE_NOT_INSTANCEOF;
660
661 case MATH_OPERATOR:
662 return (specific >= PLUS && specific <= RIGHT_SHIFT_UNSIGNED) || (specific >= NOT && specific <= LOGICAL_AND)
663 || (specific >= BITWISE_OR && specific <= BITWISE_XOR);
664
665 case LOGICAL_OPERATOR:
666 return specific >= NOT && specific <= LOGICAL_AND;
667
668 case BITWISE_OPERATOR:
669 return (specific >= BITWISE_OR && specific <= BITWISE_XOR) || specific == BITWISE_NEGATION;
670
671 case RANGE_OPERATOR:
672 return specific == DOT_DOT || specific == DOT_DOT_DOT;
673
674 case REGEX_COMPARISON_OPERATOR:

Callers 6

checkOperationMethod · 0.95
isAMethod · 0.95
isOneOfMethod · 0.95
isAllOfMethod · 0.95
isAssignmentMethod · 0.95
lookupMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected