Package org.codehaus.groovy.syntax

# Class TokenUtil

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

public class TokenUtil extends Object
Utility methods for working with tokens and operators. Provides helper functions for operator type manipulation and conversion.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Optional<Token>`
  `asAssignment(int op)`
  Converts an increment or decrement operator to its corresponding assignment operator.
  `static int`
  `removeAssignment(int op)`
  Removes the assignment portion of an assignment operator, returning the base operator.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### asAssignment

    public static Optional<Token> asAssignment(int op)
    Converts an increment or decrement operator to its corresponding assignment operator. For example, `++` becomes `+=`, and `--` becomes `-=`.
    Parameters:
      `op` - the operator type (e.g., `Types.PLUS_PLUS`, `Types.PREFIX_PLUS_PLUS`)
    Returns:
      an `Optional` containing the assignment operator token, or empty if not applicable

  - ### removeAssignment

    public static int removeAssignment(int op)
    Removes the assignment portion of an assignment operator, returning the base operator. For example, `+=` becomes `+`, `-=` becomes `-`. If the operator is not an assignment operator, returns it unchanged.
    Parameters:
      `op` - the operator type from `Types`
    Returns:
      the base operator type without assignment, or the original type if not an assignment operator