OperatorTokens¶
object OperatorTokens
Maps between Kotlin operator tokens and the operator-convention function names they desugar to (for example, + maps to plus), and groups the operator tokens by category (unary, binary, assignment, comparison, and so on).
Properties¶
ASSIGNMENT_OPERATION_NAMES¶
@JvmField
val ASSIGNMENT_OPERATION_NAMES: Map<KtSingleValueToken, Name>
Maps each augmented assignment operator token (such as += or *=) to its operator-convention function name (such as plusAssign or timesAssign).
ASSIGNMENT_OPERATION_TOKENS¶
@JvmField
val ASSIGNMENT_OPERATION_TOKENS: Map<Name, KtSingleValueToken>
The inverse of ASSIGNMENT_OPERATION_NAMES: maps each augmented assignment function name to its token.
ASSIGNMENTS_FOR_OPERATIONS¶
The inverse of OPERATIONS_FOR_ASSIGNMENTS: maps each binary operator token (such as +) to the corresponding augmented assignment token (such as +=).
BINARY_OPERATION_NAMES¶
@JvmField
val BINARY_OPERATION_NAMES: Map<KtSingleValueToken, Name>
Maps each binary operator token (such as *, +, or ..) to its operator-convention function name (such as times, plus, or rangeTo).
BINARY_OPERATION_TOKENS¶
@JvmField
val BINARY_OPERATION_TOKENS: Map<Name, KtSingleValueToken>
The inverse of BINARY_OPERATION_NAMES: maps each binary operator function name to its token.
COMPARISON_OPERATIONS¶
The comparison operator tokens (<, >, <=, and >=), all of which desugar to compareTo.
CONVENTION_NAMES¶
@JvmField
val CONVENTION_NAMES: Set<Name>
The set of fixed function names that carry a special operator meaning in Kotlin. This includes names such as get, set, invoke, iterator, equals, and compareTo, together with every unary, binary, and assignment operator name. Dynamically named componentN conventions are recognized by isConventionName but are not members of this set.
EQUALS_OPERATIONS¶
The structural equality operator tokens (== and !=), which desugar to equals.
IDENTITY_EQUALS_OPERATIONS¶
The referential equality operator tokens (=== and !==).
IN_OPERATIONS¶
The containment operator tokens (in and !in), which desugar to contains.
INCREMENT_OPERATIONS¶
The increment and decrement operator tokens (++ and --).
OPERATIONS_FOR_ASSIGNMENTS¶
Maps each augmented assignment token (such as +=) to the corresponding binary operator token (such as +).
UNARY_OPERATION_NAMES¶
@JvmField
val UNARY_OPERATION_NAMES: Map<KtSingleValueToken, Name>
Maps each unary operator token (such as ++ or -) to its operator-convention function name (such as inc or unaryMinus).
UNARY_OPERATION_TOKENS¶
@JvmField
val UNARY_OPERATION_TOKENS: Map<Name, KtSingleValueToken>
The inverse of UNARY_OPERATION_NAMES: maps each unary operator function name to its token.
Functions¶
isConventionName¶
@JvmStatic
fun isConventionName(name: Name): Boolean
Returns true if the given name is an operator-convention function name — either one of CONVENTION_NAMES or a componentN destructuring name.
operationName¶
@JvmStatic
fun operationName(token: KtToken): Name?
@JvmStatic
fun operationName(
token: KtToken,
unaryOperations: Boolean,
binaryOperations: Boolean
): Name?
Returns the operator-convention function name that the given token desugars to, or null if token is not a matching operator. unaryOperations and binaryOperations control whether unary and binary operator tokens are considered; assignment, comparison, equality, and containment operators are always considered.
operationToken¶
@JvmStatic
fun operationToken(name: Name): KtToken?