Package org.codehaus.groovy.syntax
Class TokenUtil
java.lang.Object
org.codehaus.groovy.syntax.TokenUtil
Utility methods for working with tokens and operators.
Provides helper functions for operator type manipulation and conversion.
-
Method Summary
Modifier and TypeMethodDescriptionasAssignment(int op) Converts an increment or decrement operator to its corresponding assignment operator.static intremoveAssignment(int op) Removes the assignment portion of an assignment operator, returning the base operator.
-
Method Details
-
asAssignment
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
Optionalcontaining 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 fromTypes- Returns:
- the base operator type without assignment, or the original type if not an assignment operator
-