AST class reference

Statement classes

This table lists all subclasses of Stmt.

Statement syntax CodeQL class Superclasses Remarks
; EmptyStmt    
Expr ; ExprStmt    
{ Stmt ... } Block    
if ( Expr ) Stmt else Stmt IfStmt ConditionalStmt  
if ( Expr ) Stmt
while ( Expr ) Stmt WhileStmt ConditionalStmt, LoopStmt  
do Stmt while ( Expr ) DoStmt ConditionalStmt, LoopStmt  
for ( Expr ; Expr ; Expr ) Stmt ForStmt ConditionalStmt, LoopStmt  
for ( VarAccess : Expr ) Stmt EnhancedForStmt LoopStmt  
switch ( Expr ) { SwitchCase ... } SwitchStmt    
try { Stmt ... } finally { Stmt ... } TryStmt    
return Expr ; ReturnStmt    
return ;
throw Expr ; ThrowStmt    
break ; BreakStmt JumpStmt  
break label ;
continue ; ContinueStmt JumpStmt  
continue label ;
label : Stmt LabeledStmt    
synchronized ( Expr ) Stmt SynchronizedStmt    
assert Expr : Expr ; AssertStmt    
assert Expr ;
TypeAccess name ; LocalVariableDeclStmt    
class name { Member ... } ; LocalClassDeclStmt    
this ( Expr , ... ) ; ThisConstructorInvocationStmt    
super ( Expr , ... ) ; SuperConstructorInvocationStmt    
catch ( TypeAccess name ) { Stmt ... } CatchClause   can only occur as child of a TryStmt
case Literal : Stmt ... ConstCase   can only occur as child of a SwitchStmt
default : Stmt ... DefaultCase   can only occur as child of a SwitchStmt

Expression classes

There are many expression classes, so we present them by category. All classes in this section are subclasses of Expr.

Literals

All classes in this subsection are subclasses of Literal.

Expression syntax example CodeQL class
true BooleanLiteral
23 IntegerLiteral
23l LongLiteral
4.2f FloatingPointLiteral
4.2 DoubleLiteral
'a' CharacterLiteral
"Hello" StringLiteral
null NullLiteral

Unary expressions

All classes in this subsection are subclasses of UnaryExpr.

Expression syntax example CodeQL class Superclasses Remarks
x++ PostIncExpr UnaryAssignExpr  
x-- PostDecExpr UnaryAssignExpr  
++x PreIncExpr UnaryAssignExpr  
--x PreDecExpr UnaryAssignExpr  
~x BitNotExpr BitwiseExpr see below for other subclasses of BitwiseExpr
-x MinusExpr    
+x PlusExpr    
!x LogNotExpr LogicExpr see below for other subclasses of LogicExpr

Binary expressions

All classes in this subsection are subclasses of BinaryExpr.

Expression syntax example CodeQL class Superclasses
x * y MulExpr  
x / y DivExpr  
x % y RemExpr  
x + y AddExpr  
x - y SubExpr  
x << y LShiftExpr  
x >> y RShiftExpr  
x >>> y URShiftExpr  
x && y AndLogicalExpr LogicExpr
x || y OrLogicalExpr LogicExpr
x < y LTExpr ComparisonExpr
x > y GTExpr ComparisonExpr
x <= y LEExpr ComparisonExpr
x >= y GEExpr ComparisonExpr
x == y EQExpr EqualityTest
x != y NEExpr EqualityTest
x & y AndBitwiseExpr BitwiseExpr
x | y OrBitwiseExpr BitwiseExpr
x ^ y XorBitwiseExpr BitwiseExpr

Assignment expressions

All classes in this table are subclasses of Assignment.

Expression syntax example CodeQL class Superclasses
x = y AssignExpr  
x += y AssignAddExpr AssignOp
x -= y AssignSubExpr AssignOp
x *= y AssignMulExpr AssignOp
x /= y AssignDivExpr AssignOp
x %= y AssignRemExpr AssignOp
x &= y AssignAndExpr AssignOp
x |= y AssignOrExpr AssignOp
x ^= y AssignXorExpr AssignOp
x <<= y AssignLShiftExpr AssignOp
x >>= y AssignRShiftExpr AssignOp
x >>>= y AssignURShiftExpr AssignOp

Accesses

Expression syntax examples CodeQL class
this ThisAccess
Outer.this
super SuperAccess
Outer.super
x VarAccess
e.f
a[i] ArrayAccess
f(...) MethodAccess
e.m(...)
String TypeAccess
java.lang.String
? extends Number WildcardTypeAccess
? super Double

A VarAccess that refers to a field is a FieldAccess.

Miscellaneous

Expression syntax examples CodeQL class Remarks
(int) f CastExpr  
(23 + 42) ParExpr  
o instanceof String InstanceOfExpr  
Expr ? Expr : Expr ConditionalExpr  
String. class TypeLiteral  
new A() ClassInstanceExpr  
new String[3][2] ArrayCreationExpr  
new int[] { 23, 42 }
{ 23, 42 } ArrayInit can only appear as an initializer or as a child of an ArrayCreationExpr
@Annot(key=val) Annotation