Class Types

java.lang.Object
org.codehaus.groovy.syntax.Types

public class Types extends Object
Registry of token type constants and type hierarchy definitions for the concrete syntax tree (CST) system. Provides constants for lexical tokens (literals, keywords, operators), semantic types, type classifications, and utility methods for type checking and querying. All Token, CSTNode, and Reduction nodes reference types from this class to identify their syntactic and semantic meaning.
  • Field Details

    • EOF

      public static final int EOF
      End-of-file indicator.
      See Also:
    • UNKNOWN

      public static final int UNKNOWN
      Unknown token type.
      See Also:
    • NEWLINE

      public static final int NEWLINE
      Newline character (\n).
      See Also:
    • LEFT_CURLY_BRACE

      public static final int LEFT_CURLY_BRACE
      Left curly brace ({}).
      See Also:
    • RIGHT_CURLY_BRACE

      public static final int RIGHT_CURLY_BRACE
      Right curly brace (}).
      See Also:
    • LEFT_SQUARE_BRACKET

      public static final int LEFT_SQUARE_BRACKET
      Left square bracket ([]).
      See Also:
    • RIGHT_SQUARE_BRACKET

      public static final int RIGHT_SQUARE_BRACKET
      Right square bracket (]).
      See Also:
    • LEFT_PARENTHESIS

      public static final int LEFT_PARENTHESIS
      Left parenthesis (().
      See Also:
    • RIGHT_PARENTHESIS

      public static final int RIGHT_PARENTHESIS
      Right parenthesis ()).
      See Also:
    • DOT

      public static final int DOT
      Dot operator (.).
      See Also:
    • DOT_DOT

      public static final int DOT_DOT
      Range operator (..).
      See Also:
    • DOT_DOT_DOT

      public static final int DOT_DOT_DOT
      Spread operator (...).
      See Also:
    • FIND_REGEX

      public static final int FIND_REGEX
      Regex find operator (=~).
      See Also:
    • MATCH_REGEX

      public static final int MATCH_REGEX
      Regex match operator (==~).
      See Also:
    • REGEX_PATTERN

      public static final int REGEX_PATTERN
      Regex pattern operator (~).
      See Also:
    • IMPLIES

      public static final int IMPLIES
      Implies operator (==>).
      See Also:
    • EQUAL

      public static final int EQUAL
      Assignment operator (=).
      See Also:
    • EQUALS

      public static final int EQUALS
      Alias for EQUAL.
      See Also:
    • ASSIGN

      public static final int ASSIGN
      Alias for EQUAL.
      See Also:
    • COMPARE_NOT_EQUAL

      public static final int COMPARE_NOT_EQUAL
      Not-equal comparison operator (!=).
      See Also:
    • COMPARE_IDENTICAL

      public static final int COMPARE_IDENTICAL
      Identity comparison operator (===).
      See Also:
    • COMPARE_NOT_IDENTICAL

      public static final int COMPARE_NOT_IDENTICAL
      Non-identity comparison operator (!==).
      See Also:
    • COMPARE_EQUAL

      public static final int COMPARE_EQUAL
      Equality comparison operator (==).
      See Also:
    • COMPARE_LESS_THAN

      public static final int COMPARE_LESS_THAN
      Less-than comparison operator (<).
      See Also:
    • COMPARE_LESS_THAN_EQUAL

      public static final int COMPARE_LESS_THAN_EQUAL
      Less-than-or-equal comparison operator (<=).
      See Also:
    • COMPARE_GREATER_THAN

      public static final int COMPARE_GREATER_THAN
      Greater-than comparison operator (>).
      See Also:
    • COMPARE_GREATER_THAN_EQUAL

      public static final int COMPARE_GREATER_THAN_EQUAL
      Greater-than-or-equal comparison operator (>=).
      See Also:
    • COMPARE_TO

      public static final int COMPARE_TO
      Spaceship/compare-to operator (<=>).
      See Also:
    • COMPARE_NOT_IN

      public static final int COMPARE_NOT_IN
      Not-in operator (!in).
      See Also:
    • COMPARE_NOT_INSTANCEOF

      public static final int COMPARE_NOT_INSTANCEOF
      Not-instanceof operator (!instanceof).
      See Also:
    • NOT

      public static final int NOT
      Logical negation operator (!).
      See Also:
    • LOGICAL_OR

      public static final int LOGICAL_OR
      Logical OR operator (||).
      See Also:
    • LOGICAL_AND

      public static final int LOGICAL_AND
      Logical AND operator (&&).
      See Also:
    • LOGICAL_OR_EQUAL

      public static final int LOGICAL_OR_EQUAL
      Logical OR assignment operator (||=).
      See Also:
    • LOGICAL_AND_EQUAL

      public static final int LOGICAL_AND_EQUAL
      Logical AND assignment operator (&&=).
      See Also:
    • PLUS

      public static final int PLUS
      Addition operator (+).
      See Also:
    • MINUS

      public static final int MINUS
      Subtraction operator (-).
      See Also:
    • MULTIPLY

      public static final int MULTIPLY
      Multiplication operator (*).
      See Also:
    • DIVIDE

      public static final int DIVIDE
      Division operator (/).
      See Also:
    • INTDIV

      public static final int INTDIV
      Integer division operator (\).
      See Also:
    • MOD

      public static final int MOD
      Modulo operator (%).
      See Also:
    • STAR_STAR

      public static final int STAR_STAR
      Power/exponentiation operator (**).
      See Also:
    • POWER

      public static final int POWER
      Alias for STAR_STAR.
      See Also:
    • PLUS_EQUAL

      public static final int PLUS_EQUAL
      Addition assignment operator (+=).
      See Also:
    • MINUS_EQUAL

      public static final int MINUS_EQUAL
      Subtraction assignment operator (-=).
      See Also:
    • MULTIPLY_EQUAL

      public static final int MULTIPLY_EQUAL
      Multiplication assignment operator (*=).
      See Also:
    • DIVIDE_EQUAL

      public static final int DIVIDE_EQUAL
      Division assignment operator (/=).
      See Also:
    • INTDIV_EQUAL

      public static final int INTDIV_EQUAL
      Integer division assignment operator (\=).
      See Also:
    • MOD_EQUAL

      public static final int MOD_EQUAL
      Modulo assignment operator (%=).
      See Also:
    • POWER_EQUAL

      public static final int POWER_EQUAL
      Power assignment operator (**=).
      See Also:
    • ELVIS_EQUAL

      public static final int ELVIS_EQUAL
      Elvis/null-coalescing assignment operator (?=).
      See Also:
    • PLUS_PLUS

      public static final int PLUS_PLUS
      Increment operator (++).
      See Also:
    • PREFIX_PLUS_PLUS

      public static final int PREFIX_PLUS_PLUS
      Prefix increment operator (++).
      See Also:
    • POSTFIX_PLUS_PLUS

      public static final int POSTFIX_PLUS_PLUS
      Postfix increment operator (++).
      See Also:
    • PREFIX_PLUS

      public static final int PREFIX_PLUS
      Unary plus operator (+).
      See Also:
    • MINUS_MINUS

      public static final int MINUS_MINUS
      Decrement operator (--).
      See Also:
    • PREFIX_MINUS_MINUS

      public static final int PREFIX_MINUS_MINUS
      Prefix decrement operator (--).
      See Also:
    • POSTFIX_MINUS_MINUS

      public static final int POSTFIX_MINUS_MINUS
      Postfix decrement operator (--).
      See Also:
    • PREFIX_MINUS

      public static final int PREFIX_MINUS
      Unary negation operator (-).
      See Also:
    • LEFT_SHIFT

      public static final int LEFT_SHIFT
      Left shift operator (<<).
      See Also:
    • RIGHT_SHIFT

      public static final int RIGHT_SHIFT
      Right shift operator (>>).
      See Also:
    • RIGHT_SHIFT_UNSIGNED

      public static final int RIGHT_SHIFT_UNSIGNED
      Unsigned right shift operator (>>>).
      See Also:
    • LEFT_SHIFT_EQUAL

      public static final int LEFT_SHIFT_EQUAL
      Left shift assignment operator (<<=).
      See Also:
    • RIGHT_SHIFT_EQUAL

      public static final int RIGHT_SHIFT_EQUAL
      Right shift assignment operator (>>=).
      See Also:
    • RIGHT_SHIFT_UNSIGNED_EQUAL

      public static final int RIGHT_SHIFT_UNSIGNED_EQUAL
      Unsigned right shift assignment operator (>>>=).
      See Also:
    • STAR

      public static final int STAR
      Alias for MULTIPLY.
      See Also:
    • COMMA

      public static final int COMMA
      Comma separator.
      See Also:
    • COLON

      public static final int COLON
      Colon separator.
      See Also:
    • SEMICOLON

      public static final int SEMICOLON
      Semicolon statement terminator.
      See Also:
    • QUESTION

      public static final int QUESTION
      Question mark (ternary conditional operator).
      See Also:
    • PIPE

      public static final int PIPE
      Bitwise OR operator (|).
      See Also:
    • DOUBLE_PIPE

      public static final int DOUBLE_PIPE
      Alias for LOGICAL_OR.
      See Also:
    • BITWISE_OR

      public static final int BITWISE_OR
      Alias for PIPE.
      See Also:
    • BITWISE_AND

      public static final int BITWISE_AND
      Bitwise AND operator (&).
      See Also:
    • BITWISE_XOR

      public static final int BITWISE_XOR
      Bitwise XOR operator (^).
      See Also:
    • BITWISE_OR_EQUAL

      public static final int BITWISE_OR_EQUAL
      Bitwise OR assignment operator (|=).
      See Also:
    • BITWISE_AND_EQUAL

      public static final int BITWISE_AND_EQUAL
      Bitwise AND assignment operator (&=).
      See Also:
    • BITWISE_XOR_EQUAL

      public static final int BITWISE_XOR_EQUAL
      Bitwise XOR assignment operator (^=).
      See Also:
    • BITWISE_NEGATION

      public static final int BITWISE_NEGATION
      Bitwise negation operator (~).
      See Also:
    • REMAINDER

      public static final int REMAINDER
      Remainder operator (%).
      See Also:
    • REMAINDER_EQUAL

      public static final int REMAINDER_EQUAL
      Remainder assignment operator (%=).
      See Also:
    • STRING

      public static final int STRING
      String literal token.
      See Also:
    • IDENTIFIER

      public static final int IDENTIFIER
      Identifier token.
      See Also:
    • INTEGER_NUMBER

      public static final int INTEGER_NUMBER
      Integer number literal.
      See Also:
    • DECIMAL_NUMBER

      public static final int DECIMAL_NUMBER
      Decimal number literal.
      See Also:
    • KEYWORD_PRIVATE

      public static final int KEYWORD_PRIVATE
      Visibility modifier keyword private.
      See Also:
    • KEYWORD_PROTECTED

      public static final int KEYWORD_PROTECTED
      Visibility modifier keyword protected.
      See Also:
    • KEYWORD_PUBLIC

      public static final int KEYWORD_PUBLIC
      Visibility modifier keyword public.
      See Also:
    • KEYWORD_ABSTRACT

      public static final int KEYWORD_ABSTRACT
      Method modifier keyword abstract.
      See Also:
    • KEYWORD_FINAL

      public static final int KEYWORD_FINAL
      Declaration modifier keyword final.
      See Also:
    • KEYWORD_NATIVE

      public static final int KEYWORD_NATIVE
      Method modifier keyword native.
      See Also:
    • KEYWORD_TRANSIENT

      public static final int KEYWORD_TRANSIENT
      Field modifier keyword transient.
      See Also:
    • KEYWORD_VOLATILE

      public static final int KEYWORD_VOLATILE
      Field modifier keyword volatile.
      See Also:
    • KEYWORD_SYNCHRONIZED

      public static final int KEYWORD_SYNCHRONIZED
      Method modifier keyword synchronized.
      See Also:
    • KEYWORD_STATIC

      public static final int KEYWORD_STATIC
      Declaration modifier keyword static.
      See Also:
    • KEYWORD_DEF

      public static final int KEYWORD_DEF
      Function definition keyword def.
      See Also:
    • KEYWORD_DEFMACRO

      public static final int KEYWORD_DEFMACRO
      Macro definition keyword defmacro.
      See Also:
    • KEYWORD_CLASS

      public static final int KEYWORD_CLASS
      Class definition keyword class.
      See Also:
    • KEYWORD_INTERFACE

      public static final int KEYWORD_INTERFACE
      Interface definition keyword interface.
      See Also:
    • KEYWORD_MIXIN

      public static final int KEYWORD_MIXIN
      Mixin definition keyword mixin.
      See Also:
    • KEYWORD_IMPLEMENTS

      public static final int KEYWORD_IMPLEMENTS
      Implements keyword implements.
      See Also:
    • KEYWORD_EXTENDS

      public static final int KEYWORD_EXTENDS
      Extends keyword extends.
      See Also:
    • KEYWORD_THIS

      public static final int KEYWORD_THIS
      This keyword this.
      See Also:
    • KEYWORD_SUPER

      public static final int KEYWORD_SUPER
      Super keyword super.
      See Also:
    • KEYWORD_INSTANCEOF

      public static final int KEYWORD_INSTANCEOF
      Instanceof operator keyword instanceof.
      See Also:
    • KEYWORD_PROPERTY

      public static final int KEYWORD_PROPERTY
      Property declaration keyword property (deprecated).
      See Also:
    • KEYWORD_NEW

      public static final int KEYWORD_NEW
      Object instantiation keyword new.
      See Also:
    • KEYWORD_PACKAGE

      public static final int KEYWORD_PACKAGE
      Package declaration keyword package.
      See Also:
    • KEYWORD_IMPORT

      public static final int KEYWORD_IMPORT
      Import statement keyword import.
      See Also:
    • KEYWORD_AS

      public static final int KEYWORD_AS
      Import alias keyword as.
      See Also:
    • KEYWORD_RETURN

      public static final int KEYWORD_RETURN
      Return statement keyword return.
      See Also:
    • KEYWORD_IF

      public static final int KEYWORD_IF
      Conditional keyword if.
      See Also:
    • KEYWORD_ELSE

      public static final int KEYWORD_ELSE
      Conditional keyword else.
      See Also:
    • KEYWORD_DO

      public static final int KEYWORD_DO
      Loop keyword do.
      See Also:
    • KEYWORD_WHILE

      public static final int KEYWORD_WHILE
      Loop keyword while.
      See Also:
    • KEYWORD_FOR

      public static final int KEYWORD_FOR
      Loop keyword for.
      See Also:
    • KEYWORD_IN

      public static final int KEYWORD_IN
      Loop separator keyword in.
      See Also:
    • KEYWORD_BREAK

      public static final int KEYWORD_BREAK
      Loop control keyword break.
      See Also:
    • KEYWORD_CONTINUE

      public static final int KEYWORD_CONTINUE
      Loop control keyword continue.
      See Also:
    • KEYWORD_SWITCH

      public static final int KEYWORD_SWITCH
      Switch statement keyword switch.
      See Also:
    • KEYWORD_CASE

      public static final int KEYWORD_CASE
      Switch case keyword case.
      See Also:
    • KEYWORD_DEFAULT

      public static final int KEYWORD_DEFAULT
      Switch default keyword default.
      See Also:
    • KEYWORD_TRY

      public static final int KEYWORD_TRY
      Exception handling keyword try.
      See Also:
    • KEYWORD_CATCH

      public static final int KEYWORD_CATCH
      Exception handling keyword catch.
      See Also:
    • KEYWORD_FINALLY

      public static final int KEYWORD_FINALLY
      Exception handling keyword finally.
      See Also:
    • KEYWORD_THROW

      public static final int KEYWORD_THROW
      Exception throwing keyword throw.
      See Also:
    • KEYWORD_THROWS

      public static final int KEYWORD_THROWS
      Exception declaration keyword throws.
      See Also:
    • KEYWORD_ASSERT

      public static final int KEYWORD_ASSERT
      Assertion keyword assert.
      See Also:
    • KEYWORD_VOID

      public static final int KEYWORD_VOID
      Primitive type keyword void.
      See Also:
    • KEYWORD_BOOLEAN

      public static final int KEYWORD_BOOLEAN
      Primitive type keyword boolean.
      See Also:
    • KEYWORD_BYTE

      public static final int KEYWORD_BYTE
      Primitive type keyword byte.
      See Also:
    • KEYWORD_SHORT

      public static final int KEYWORD_SHORT
      Primitive type keyword short.
      See Also:
    • KEYWORD_INT

      public static final int KEYWORD_INT
      Primitive type keyword int.
      See Also:
    • KEYWORD_LONG

      public static final int KEYWORD_LONG
      Primitive type keyword long.
      See Also:
    • KEYWORD_FLOAT

      public static final int KEYWORD_FLOAT
      Primitive type keyword float.
      See Also:
    • KEYWORD_DOUBLE

      public static final int KEYWORD_DOUBLE
      Primitive type keyword double.
      See Also:
    • KEYWORD_CHAR

      public static final int KEYWORD_CHAR
      Primitive type keyword char.
      See Also:
    • KEYWORD_TRUE

      public static final int KEYWORD_TRUE
      Boolean literal keyword true.
      See Also:
    • KEYWORD_FALSE

      public static final int KEYWORD_FALSE
      Boolean literal keyword false.
      See Also:
    • KEYWORD_NULL

      public static final int KEYWORD_NULL
      Null literal keyword null.
      See Also:
    • KEYWORD_CONST

      public static final int KEYWORD_CONST
      Reserved keyword const.
      See Also:
    • KEYWORD_GOTO

      public static final int KEYWORD_GOTO
      Reserved keyword goto.
      See Also:
    • SYNTH_COMPILATION_UNIT

      public static final int SYNTH_COMPILATION_UNIT
      Synthetic compilation unit node type.
      See Also:
    • SYNTH_CLASS

      public static final int SYNTH_CLASS
      Synthetic class declaration node type.
      See Also:
    • SYNTH_INTERFACE

      public static final int SYNTH_INTERFACE
      Synthetic interface declaration node type.
      See Also:
    • SYNTH_MIXIN

      public static final int SYNTH_MIXIN
      Synthetic mixin declaration node type.
      See Also:
    • SYNTH_METHOD

      public static final int SYNTH_METHOD
      Synthetic method declaration node type.
      See Also:
    • SYNTH_PROPERTY

      public static final int SYNTH_PROPERTY
      Synthetic property declaration node type.
      See Also:
    • SYNTH_PARAMETER_DECLARATION

      public static final int SYNTH_PARAMETER_DECLARATION
      Synthetic parameter declaration node type.
      See Also:
    • SYNTH_LIST

      public static final int SYNTH_LIST
      Synthetic list node type.
      See Also:
    • SYNTH_MAP

      public static final int SYNTH_MAP
      Synthetic map literal node type.
      See Also:
    • SYNTH_GSTRING

      public static final int SYNTH_GSTRING
      Synthetic GString literal node type.
      See Also:
    • SYNTH_METHOD_CALL

      public static final int SYNTH_METHOD_CALL
      Synthetic method call node type.
      See Also:
    • SYNTH_CAST

      public static final int SYNTH_CAST
      Synthetic type cast node type.
      See Also:
    • SYNTH_BLOCK

      public static final int SYNTH_BLOCK
      Synthetic block node type.
      See Also:
    • SYNTH_CLOSURE

      public static final int SYNTH_CLOSURE
      Synthetic closure literal node type.
      See Also:
    • SYNTH_LABEL

      public static final int SYNTH_LABEL
      Synthetic label node type.
      See Also:
    • SYNTH_TERNARY

      public static final int SYNTH_TERNARY
      Synthetic ternary expression type.
      See Also:
    • SYNTH_TUPLE

      public static final int SYNTH_TUPLE
      Synthetic tuple node type.
      See Also:
    • SYNTH_VARIABLE_DECLARATION

      public static final int SYNTH_VARIABLE_DECLARATION
      Synthetic variable declaration type.
      See Also:
    • GSTRING_START

      public static final int GSTRING_START
      GString start marker token.
      See Also:
    • GSTRING_END

      public static final int GSTRING_END
      GString end marker token.
      See Also:
    • GSTRING_EXPRESSION_START

      public static final int GSTRING_EXPRESSION_START
      GString embedded expression start marker.
      See Also:
    • GSTRING_EXPRESSION_END

      public static final int GSTRING_EXPRESSION_END
      GString embedded expression end marker.
      See Also:
    • ANY

      public static final int ANY
      Type matching any token.
      See Also:
    • NOT_EOF

      public static final int NOT_EOF
      Type matching any non-EOF token.
      See Also:
    • GENERAL_END_OF_STATEMENT

      public static final int GENERAL_END_OF_STATEMENT
      Type category for general statement terminators.
      See Also:
    • ANY_END_OF_STATEMENT

      public static final int ANY_END_OF_STATEMENT
      Type category for any statement terminator.
      See Also:
    • ASSIGNMENT_OPERATOR

      public static final int ASSIGNMENT_OPERATOR
      Type category for assignment operators.
      See Also:
    • COMPARISON_OPERATOR

      public static final int COMPARISON_OPERATOR
      Type category for comparison operators.
      See Also:
    • MATH_OPERATOR

      public static final int MATH_OPERATOR
      Type category for mathematical operators.
      See Also:
    • LOGICAL_OPERATOR

      public static final int LOGICAL_OPERATOR
      Type category for logical operators.
      See Also:
    • RANGE_OPERATOR

      public static final int RANGE_OPERATOR
      Type category for range operators (.., ...).
      See Also:
    • REGEX_COMPARISON_OPERATOR

      public static final int REGEX_COMPARISON_OPERATOR
      Type category for regex comparison operators.
      See Also:
    • DEREFERENCE_OPERATOR

      public static final int DEREFERENCE_OPERATOR
      Type category for dereference operators.
      See Also:
    • BITWISE_OPERATOR

      public static final int BITWISE_OPERATOR
      Type category for bitwise operators.
      See Also:
    • INSTANCEOF_OPERATOR

      public static final int INSTANCEOF_OPERATOR
      Type category for instanceof operators.
      See Also:
    • PREFIX_OPERATOR

      public static final int PREFIX_OPERATOR
      Type category for prefix operators.
      See Also:
    • POSTFIX_OPERATOR

      public static final int POSTFIX_OPERATOR
      Type category for postfix operators.
      See Also:
    • INFIX_OPERATOR

      public static final int INFIX_OPERATOR
      Type category for infix operators.
      See Also:
    • PREFIX_OR_INFIX_OPERATOR

      public static final int PREFIX_OR_INFIX_OPERATOR
      Type category for operators that can be prefix or infix.
      See Also:
    • PURE_PREFIX_OPERATOR

      public static final int PURE_PREFIX_OPERATOR
      Type category for operators that are only prefix.
      See Also:
    • KEYWORD

      public static final int KEYWORD
      Type category for keywords.
      See Also:
    • SYMBOL

      public static final int SYMBOL
      Type category for symbols.
      See Also:
    • LITERAL

      public static final int LITERAL
      Type category for literal values.
      See Also:
    • NUMBER

      public static final int NUMBER
      Type category for numeric values.
      See Also:
    • SIGN

      public static final int SIGN
      Type category for sign operators.
      See Also:
    • NAMED_VALUE

      public static final int NAMED_VALUE
      Type category for named values.
      See Also:
    • TRUTH_VALUE

      public static final int TRUTH_VALUE
      Type category for boolean/truth values.
      See Also:
    • PRIMITIVE_TYPE

      public static final int PRIMITIVE_TYPE
      Type category for primitive types.
      See Also:
    • CREATABLE_PRIMITIVE_TYPE

      public static final int CREATABLE_PRIMITIVE_TYPE
      Type category for instantiable primitive types.
      See Also:
    • LOOP

      public static final int LOOP
      Type category for loop statements.
      See Also:
    • RESERVED_KEYWORD

      public static final int RESERVED_KEYWORD
      Type category for reserved keywords.
      See Also:
    • KEYWORD_IDENTIFIER

      public static final int KEYWORD_IDENTIFIER
      Type category for keyword identifiers.
      See Also:
    • SYNTHETIC

      public static final int SYNTHETIC
      Type category for synthetic/generated nodes.
      See Also:
    • TYPE_DECLARATION

      public static final int TYPE_DECLARATION
      Type category for type declarations.
      See Also:
    • DECLARATION_MODIFIER

      public static final int DECLARATION_MODIFIER
      Type category for declaration modifiers.
      See Also:
    • TYPE_NAME

      public static final int TYPE_NAME
      Type category for type names.
      See Also:
    • CREATABLE_TYPE_NAME

      public static final int CREATABLE_TYPE_NAME
      Type category for instantiable type names.
      See Also:
    • MATCHED_CONTAINER

      public static final int MATCHED_CONTAINER
      Type category for matched container syntax.
      See Also:
    • LEFT_OF_MATCHED_CONTAINER

      public static final int LEFT_OF_MATCHED_CONTAINER
      Type category for left container delimiters.
      See Also:
    • RIGHT_OF_MATCHED_CONTAINER

      public static final int RIGHT_OF_MATCHED_CONTAINER
      Type category for right container delimiters.
      See Also:
    • EXPRESSION

      public static final int EXPRESSION
      Type category for expressions.
      See Also:
    • OPERATOR_EXPRESSION

      public static final int OPERATOR_EXPRESSION
      Type category for operator expressions.
      See Also:
    • SYNTH_EXPRESSION

      public static final int SYNTH_EXPRESSION
      Type category for synthetic expressions.
      See Also:
    • KEYWORD_EXPRESSION

      public static final int KEYWORD_EXPRESSION
      Type category for keyword-based expressions.
      See Also:
    • LITERAL_EXPRESSION

      public static final int LITERAL_EXPRESSION
      Type category for literal expressions.
      See Also:
    • ARRAY_EXPRESSION

      public static final int ARRAY_EXPRESSION
      Type category for array expressions.
      See Also:
    • SIMPLE_EXPRESSION

      public static final int SIMPLE_EXPRESSION
      Type category for simple expressions.
      See Also:
    • COMPLEX_EXPRESSION

      public static final int COMPLEX_EXPRESSION
      Type category for complex expressions.
      See Also:
    • PARAMETER_TERMINATORS

      public static final int PARAMETER_TERMINATORS
      Type category for parameter list terminators.
      See Also:
    • ARRAY_ITEM_TERMINATORS

      public static final int ARRAY_ITEM_TERMINATORS
      Type category for array item terminators.
      See Also:
    • TYPE_LIST_TERMINATORS

      public static final int TYPE_LIST_TERMINATORS
      Type category for type list terminators.
      See Also:
    • OPTIONAL_DATATYPE_FOLLOWERS

      public static final int OPTIONAL_DATATYPE_FOLLOWERS
      Type category for optional datatype followers.
      See Also:
    • SWITCH_BLOCK_TERMINATORS

      public static final int SWITCH_BLOCK_TERMINATORS
      Type category for switch block terminators.
      See Also:
    • SWITCH_ENTRIES

      public static final int SWITCH_ENTRIES
      Type category for switch case entries.
      See Also:
    • METHOD_CALL_STARTERS

      public static final int METHOD_CALL_STARTERS
      Type category for method call starting tokens.
      See Also:
    • UNSAFE_OVER_NEWLINES

      public static final int UNSAFE_OVER_NEWLINES
      Type category for tokens unsafe across newlines.
      See Also:
    • PRECLUDES_CAST_OPERATOR

      public static final int PRECLUDES_CAST_OPERATOR
      Type category for tokens that prevent cast parsing.
      See Also:
  • Constructor Details

    • Types

      public Types()
  • Method Details

    • isAssignment

      public static boolean isAssignment(int type)
      Returns true if the specified type represents an assignment operator. Assignment operators include simple assignment (=) and compound assignments (+=, -=, *=, etc.).
      Parameters:
      type - the token type to check
      Returns:
      true if the type is an assignment operator
      Since:
      3.0.0
    • ofType

      public static boolean ofType(int specific, int general)
      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.
      Parameters:
      specific - the specific token type to check
      general - the general type category
      Returns:
      true if the specific type is within the general category
    • canMean

      public static boolean canMean(int actual, int preferred)
      Determines if a type can be interpreted as another type. This is orthogonal to ofType(int, int) and is used for semantic flexibility (e.g., an identifier can be viewed as a class name).
      Parameters:
      actual - the actual type being checked
      preferred - the desired interpretation
      Returns:
      true if the actual type can be reinterpreted as the preferred type
    • makePrefix

      public static void makePrefix(CSTNode node, boolean throwIfInvalid)
      Converts an operator node's meaning to a prefix operator variant. For example, converts PLUS to PREFIX_PLUS.
      Parameters:
      node - the node whose meaning is to be modified
      throwIfInvalid - if true, throws GroovyBugError if the type cannot be converted
    • makePostfix

      public static void makePostfix(CSTNode node, boolean throwIfInvalid)
      Converts an operator node's meaning to a postfix operator variant. For example, converts PLUS_PLUS to POSTFIX_PLUS_PLUS.
      Parameters:
      node - the node whose meaning is to be modified
      throwIfInvalid - if true, throws GroovyBugError if the type cannot be converted
    • getPrecedence

      public static int getPrecedence(int type, boolean throwIfInvalid)
      Returns the operator precedence level for the specified type. Lower precedence values bind tighter (evaluate first). For example, multiplication (MULTIPLY) has higher precedence than addition (PLUS).
      Parameters:
      type - the operator type to check
      throwIfInvalid - if true, throws GroovyBugError for non-operators; if false, returns -1 for non-operators
      Returns:
      the precedence level (0-85), or -1 if the type is not an operator and throwIfInvalid is false
      Throws:
      GroovyBugError - if the type is not an operator and throwIfInvalid is true
    • getKeywords

      public static Collection<String> getKeywords()
      Returns an unmodifiable collection of all recognized keywords.
      Returns:
      collection of keyword strings
    • isKeyword

      public static boolean isKeyword(String text)
      Returns true if the specified text is a recognized keyword.
      Parameters:
      text - the text to check
      Returns:
      true if the text is a keyword
    • lookup

      public static int lookup(String text, int filter)
      Returns the token type for the specified symbol or keyword text. Returns UNKNOWN if the text is not found. Optionally filters the result by type (e.g., restrict to keywords only).
      Parameters:
      text - the text to look up (e.g., "def", "+", "if")
      filter - a type filter (KEYWORD, SYMBOL, or UNKNOWN for no filter)
      Returns:
      the token type, or UNKNOWN if not found or doesn't match the filter
    • lookupKeyword

      public static int lookupKeyword(String text)
      Returns the token type for the specified keyword text. Only matches keywords, not symbols.
      Parameters:
      text - the keyword text (e.g., "def", "if", "class")
      Returns:
      the keyword type constant, or UNKNOWN if not a recognized keyword
    • lookupSymbol

      public static int lookupSymbol(String text)
      Returns the token type for the specified symbol text. Only matches symbols (operators, delimiters), not keywords.
      Parameters:
      text - the symbol text (e.g., "+", "-", "{", ".")
      Returns:
      the symbol type constant, or UNKNOWN if not a recognized symbol
    • getText

      public static String getText(int type)
      Returns the text representation for the specified token type. For symbols and keywords, this is the canonical text (e.g., "def", "+", "->").
      Parameters:
      type - a token type constant from this class
      Returns:
      the text representation, or empty string if the type has no text mapping
    • getDescription

      public static String getDescription(int type)
      Returns a human-readable description of the specified token type. Useful for error messages and debugging. For example, PLUS might return "+".
      Parameters:
      type - the token type constant
      Returns:
      a description string, or "<>" if the type has no description