pub enum Expr {
Show 21 variants
Literal(Lit),
Ident(Ident),
This(Span),
Super(Span),
Paren {
paren_span: (Span, Span),
expr: Box<Expr>,
},
ClassLit {
type_expr: Box<Type>,
dot_span: Span,
class_span: Span,
},
FieldAccess(FieldAccessExpr),
MethodCall(MethodCallExpr),
ArrayAccess(ArrayAccessExpr),
MethodRef(MethodRefExpr),
ArrayNew(ArrayNewExpr),
Cast(CastExpr),
Binary(BinaryExpr),
Unary(UnaryExpr),
Instanceof(InstanceofExpr),
Assign(AssignExpr),
Conditional(ConditionalExpr),
Lambda(LambdaExpr),
Switch(SwitchExpr),
NewClass(NewClassExpr),
ArrayInit(ArrayInitExpr),
}Expand description
A Java expression.
Expressions are represented in a mostly-desugared form, following the JLS grammar hierarchy.
Variants§
Literal(Lit)
A literal value.
Ident(Ident)
An identifier expression.
This(Span)
this
Super(Span)
Super
Paren
Parenthesized expression: (expr)
ClassLit
Class literal: String.class, int[].class
FieldAccess(FieldAccessExpr)
Field access: expr.field
MethodCall(MethodCallExpr)
Method invocation: method(args), obj.method(args)
ArrayAccess(ArrayAccessExpr)
Array access: array[index]
MethodRef(MethodRefExpr)
Method reference: String::valueOf, System.out::println
ArrayNew(ArrayNewExpr)
Array creation: new int[]{1, 2, 3}, new String[10]
Cast(CastExpr)
Type cast: (int) expr
Binary(BinaryExpr)
Binary operation: a + b
Unary(UnaryExpr)
Unary operation: -x, !flag
Instanceof(InstanceofExpr)
instanceof: obj instanceof String, obj instanceof String s
Assign(AssignExpr)
Assignment: x = 5, x += 1
Conditional(ConditionalExpr)
Ternary conditional: cond ? a : b
Lambda(LambdaExpr)
Lambda expression: x -> x + 1, (x, y) -> x + y
Switch(SwitchExpr)
Switch expression (Java 14+): switch (x) { case 1 -> "one"; ... }
NewClass(NewClassExpr)
Class instance creation (anonymous class): new Foo() { ... }
ArrayInit(ArrayInitExpr)
Array initializer: {1, 2, 3}