Merge pull request #3683 from owen-mc/improve-ast-class-reference-for-java

Improve ast class reference for java
This commit is contained in:
Owen Mansel-Chan
2020-06-15 16:25:25 +01:00
committed by GitHub

View File

@@ -5,80 +5,72 @@ CodeQL has a large selection of classes for representing the abstract syntax tre
.. include:: ../../reusables/abstract-syntax-tree.rst
.. _Expr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$Expr.html
.. _Stmt: https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$Stmt.html
.. _VarAccess: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$VarAccess.html
.. _SwitchCase: https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$SwitchCase.html
.. _TypeAccess: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$TypeAccess.html
.. _Member: https://help.semmle.com/qldoc/java/semmle/code/java/Member.qll/type.Member$Member.html
.. _Literal: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$Literal.html
Statement classes
-----------------
This table lists all subclasses of `Stmt`_.
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| Statement syntax | CodeQL class | Superclasses | Remarks |
+========================================================================+===========================================================================================================================================================+===================================+=============================================+
| ``;`` | `EmptyStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$EmptyStmt.html>`__ | | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| `Expr`_ ``;`` | `ExprStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$ExprStmt.html>`__ | | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``{`` `Stmt`_ ``... }`` | `Block <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$Block.html>`__ | | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``if (`` `Expr`_ ``)`` `Stmt`_ ``else`` `Stmt`_ | `IfStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$IfStmt.html>`__ | ``ConditionalStmt`` | |
+------------------------------------------------------------------------+ + + +
| ``if (`` `Expr`_ ``)`` `Stmt`_ | | | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``while (`` `Expr`_ ``)`` `Stmt`_ | `WhileStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$WhileStmt.html>`__ | ``ConditionalStmt``, ``LoopStmt`` | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``do`` `Stmt`_ ``while (`` `Expr`_ ``)`` | `DoStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$DoStmt.html>`__ | ``ConditionalStmt``, ``LoopStmt`` | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``for (`` `Expr`_ ``;`` `Expr`_ ``;`` `Expr`_ ``)`` `Stmt`_ | `ForStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$ForStmt.html>`__ | ``ConditionalStmt``, ``LoopStmt`` | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``for (`` `VarAccess`_ ``:`` `Expr`_ ``)`` `Stmt`_ | `EnhancedForStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$EnhancedForStmt.html>`__ | ``LoopStmt`` | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``switch (`` `Expr`_ ``) {`` `SwitchCase`_ ``... }`` | `SwitchStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$SwitchStmt.html>`__ | | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``try {`` `Stmt`_ ``... } finally {`` `Stmt`_ ``... }`` | `TryStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$TryStmt.html>`__ | | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``return`` `Expr`_ ``;`` | `ReturnStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$ReturnStmt.html>`__ | | |
+------------------------------------------------------------------------+ + + +
| ``return ;`` | | | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``throw`` `Expr`_ ``;`` | `ThrowStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$ThrowStmt.html>`__ | | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``break ;`` | `BreakStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$BreakStmt.html>`__ | ``JumpStmt`` | |
+------------------------------------------------------------------------+ + + +
| ``break label ;`` | | | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``continue ;`` | `ContinueStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$ContinueStmt.html>`__ | ``JumpStmt`` | |
+------------------------------------------------------------------------+ + + +
| ``continue label ;`` | | | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``label :`` `Stmt`_ | `LabeledStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$LabeledStmt.html>`__ | | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``synchronized (`` `Expr`_ ``)`` `Stmt`_ | `SynchronizedStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$SynchronizedStmt.html>`__ | | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``assert`` `Expr`_ ``:`` `Expr`_ ``;`` | `AssertStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$AssertStmt.html>`__ | | |
+------------------------------------------------------------------------+ + + +
| ``assert`` `Expr`_ ``;`` | | | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| `TypeAccess`_ ``name ;`` | `LocalVariableDeclStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$LocalVariableDeclStmt.html>`__ | | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``class name {`` `Member`_ ``... } ;`` | `LocalClassDeclStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$LocalClassDeclStmt.html>`__ | | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``this (`` `Expr`_ ``, ... ) ;`` | `ThisConstructorInvocationStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$ThisConstructorInvocationStmt.html>`__ | | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``super (`` `Expr`_ ``, ... ) ;`` | `SuperConstructorInvocationStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$SuperConstructorInvocationStmt.html>`__ | | |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``catch (`` `TypeAccess`_ ``name ) {`` `Stmt`_ ``... }`` | `CatchClause <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$CatchClause.html>`__ | | can only occur as child of a ``TryStmt`` |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``case`` `Literal`_ ``:`` `Stmt`_ ``...`` | `ConstCase <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$ConstCase.html>`__ | | can only occur as child of a ``SwitchStmt`` |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
| ``default :`` `Stmt`_ ``...`` | `DefaultCase <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$DefaultCase.html>`__ | | can only occur as child of a ``SwitchStmt`` |
+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------------------------------------+
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| Statement syntax | CodeQL class | Superclasses | Remarks |
+============================================================================+===========================================================================================================================================================+=================================+============================================+
| ``;`` | `EmptyStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$EmptyStmt.html>`__ | | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| `Expr`_ ``;`` | `ExprStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$ExprStmt.html>`__ | | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``{`` `Stmt`_ ``... }`` | `Block <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$Block.html>`__ | | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``if (`` `Expr`_ ``)`` `Stmt`_ ``else`` `Stmt`_ | `IfStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$IfStmt.html>`__ | `ConditionalStmt`_ | |
+----------------------------------------------------------------------------+ | | |
| ``if (`` `Expr`_ ``)`` `Stmt`_ | | | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``while (`` `Expr`_ ``)`` `Stmt`_ | `WhileStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$WhileStmt.html>`__ | `ConditionalStmt`_, `LoopStmt`_ | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``do`` `Stmt`_ ``while (`` `Expr`_ ``)`` | `DoStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$DoStmt.html>`__ | `ConditionalStmt`_, `LoopStmt`_ | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``for (`` `Expr`_ ``;`` `Expr`_ ``;`` `Expr`_ ``)`` `Stmt`_ | `ForStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$ForStmt.html>`__ | `ConditionalStmt`_, `LoopStmt`_ | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``for (`` `VarAccess`_ ``:`` `Expr`_ ``)`` `Stmt`_ | `EnhancedForStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$EnhancedForStmt.html>`__ | `LoopStmt`_ | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``switch (`` `Expr`_ ``) {`` `SwitchCase`_ ``... }`` | `SwitchStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$SwitchStmt.html>`__ | | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``try {`` `Stmt`_ ``... } finally {`` `Stmt`_ ``... }`` | `TryStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$TryStmt.html>`__ | | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``return`` `Expr`_ ``;`` | `ReturnStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$ReturnStmt.html>`__ | | |
+----------------------------------------------------------------------------+ | | |
| ``return ;`` | | | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``throw`` `Expr`_ ``;`` | `ThrowStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$ThrowStmt.html>`__ | | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``break ;`` | `BreakStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$BreakStmt.html>`__ | `JumpStmt`_ | |
+----------------------------------------------------------------------------+ | | |
| ``break label ;`` | | | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``continue ;`` | `ContinueStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$ContinueStmt.html>`__ | `JumpStmt`_ | |
+----------------------------------------------------------------------------+ | | |
| ``continue label ;`` | | | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``label :`` `Stmt`_ | `LabeledStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$LabeledStmt.html>`__ | | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``synchronized (`` `Expr`_ ``)`` `Stmt`_ | `SynchronizedStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$SynchronizedStmt.html>`__ | | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``assert`` `Expr`_ ``:`` `Expr`_ ``;`` | `AssertStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$AssertStmt.html>`__ | | |
+----------------------------------------------------------------------------+ | | |
| ``assert`` `Expr`_ ``;`` | | | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| `TypeAccess`_ ``name ;`` | `LocalVariableDeclStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$LocalVariableDeclStmt.html>`__ | | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``class name {`` `Member`_ ``... } ;`` | `LocalClassDeclStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$LocalClassDeclStmt.html>`__ | | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``this (`` `Expr`_ ``, ... ) ;`` | `ThisConstructorInvocationStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$ThisConstructorInvocationStmt.html>`__ | | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``super (`` `Expr`_ ``, ... ) ;`` | `SuperConstructorInvocationStmt <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$SuperConstructorInvocationStmt.html>`__ | | |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``catch (`` `TypeAccess`_ ``name ) {`` `Stmt`_ ``... }`` | `CatchClause <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$CatchClause.html>`__ | | can only occur as child of a `TryStmt`_ |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``case`` `Literal`_ ``:`` `Stmt`_ ``...`` | `ConstCase <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$ConstCase.html>`__ | | can only occur as child of a `SwitchStmt`_ |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
| ``default :`` `Stmt`_ ``...`` | `DefaultCase <https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$DefaultCase.html>`__ | | can only occur as child of a `SwitchStmt`_ |
+----------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+--------------------------------------------+
Expression classes
------------------
@@ -90,130 +82,130 @@ Literals
All classes in this subsection are subclasses of `Literal <https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$Literal.html>`__.
+---------------------------+--------------------------+
| Expression syntax example | CodeQL class |
+===========================+==========================+
| ``true`` | ``BooleanLiteral`` |
+---------------------------+--------------------------+
| ``23`` | ``IntegerLiteral`` |
+---------------------------+--------------------------+
| ``23l`` | ``LongLiteral`` |
+---------------------------+--------------------------+
| ``4.2f`` | ``FloatingPointLiteral`` |
+---------------------------+--------------------------+
| ``4.2`` | ``DoubleLiteral`` |
+---------------------------+--------------------------+
| ``'a'`` | ``CharacterLiteral`` |
+---------------------------+--------------------------+
| ``"Hello"`` | ``StringLiteral`` |
+---------------------------+--------------------------+
| ``null`` | ``NullLiteral`` |
+---------------------------+--------------------------+
+---------------------------+-------------------------+
| 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 <https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$UnaryExpr.html>`__.
+---------------------------+-----------------+---------------------+---------------------------------------------------+
| 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`` |
+---------------------------+-----------------+---------------------+---------------------------------------------------+
+-------------------+----------------+--------------------+--------------------------------------------------+
| Expression syntax | CodeQL class | Superclasses | Remarks |
+===================+================+====================+==================================================+
| `Expr`_\ ``++`` | `PostIncExpr`_ | `UnaryAssignExpr`_ | |
+-------------------+----------------+--------------------+--------------------------------------------------+
| `Expr`_\ ``--`` | `PostDecExpr`_ | `UnaryAssignExpr`_ | |
+-------------------+----------------+--------------------+--------------------------------------------------+
| ``++``\ `Expr`_ | `PreIncExpr`_ | `UnaryAssignExpr`_ | |
+-------------------+----------------+--------------------+--------------------------------------------------+
| ``--``\ `Expr`_ | `PreDecExpr`_ | `UnaryAssignExpr`_ | |
+-------------------+----------------+--------------------+--------------------------------------------------+
| ``~``\ `Expr`_ | `BitNotExpr`_ | `BitwiseExpr`_ | see below for other subclasses of `BitwiseExpr`_ |
+-------------------+----------------+--------------------+--------------------------------------------------+
| ``-``\ `Expr`_ | `MinusExpr`_ | | |
+-------------------+----------------+--------------------+--------------------------------------------------+
| ``+``\ `Expr`_ | `PlusExpr`_ | | |
+-------------------+----------------+--------------------+--------------------------------------------------+
| ``!``\ `Expr`_ | `LogNotExpr`_ | `LogicExpr`_ | see below for other subclasses of `LogicExpr`_ |
+-------------------+----------------+--------------------+--------------------------------------------------+
Binary expressions
~~~~~~~~~~~~~~~~~~
All classes in this subsection are subclasses of `BinaryExpr <https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$BinaryExpr.html>`__.
+---------------------------+--------------------+--------------------+
| 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`` |
+---------------------------+--------------------+--------------------+
+-------------------------+-------------------+-------------------+
| Expression syntax | CodeQL class | Superclasses |
+=========================+===================+===================+
| `Expr`_ ``*`` `Expr`_ | `MulExpr`_ | |
+-------------------------+-------------------+-------------------+
| `Expr`_ ``/`` `Expr`_ | `DivExpr`_ | |
+-------------------------+-------------------+-------------------+
| `Expr`_ ``%`` `Expr`_ | `RemExpr`_ | |
+-------------------------+-------------------+-------------------+
| `Expr`_ ``+`` `Expr`_ | `AddExpr`_ | |
+-------------------------+-------------------+-------------------+
| `Expr`_ ``-`` `Expr`_ | `SubExpr`_ | |
+-------------------------+-------------------+-------------------+
| `Expr`_ ``<<`` `Expr`_ | `LShiftExpr`_ | |
+-------------------------+-------------------+-------------------+
| `Expr`_ ``>>`` `Expr`_ | `RShiftExpr`_ | |
+-------------------------+-------------------+-------------------+
| `Expr`_ ``>>>`` `Expr`_ | `URShiftExpr`_ | |
+-------------------------+-------------------+-------------------+
| `Expr`_ ``&&`` `Expr`_ | `AndLogicalExpr`_ | `LogicExpr`_ |
+-------------------------+-------------------+-------------------+
| `Expr`_ ``||`` `Expr`_ | `OrLogicalExpr`_ | `LogicExpr`_ |
+-------------------------+-------------------+-------------------+
| `Expr`_ ``<`` `Expr`_ | `LTExpr`_ | `ComparisonExpr`_ |
+-------------------------+-------------------+-------------------+
| `Expr`_ ``>`` `Expr`_ | `GTExpr`_ | `ComparisonExpr`_ |
+-------------------------+-------------------+-------------------+
| `Expr`_ ``<=`` `Expr`_ | `LEExpr`_ | `ComparisonExpr`_ |
+-------------------------+-------------------+-------------------+
| `Expr`_ ``>=`` `Expr`_ | `GEExpr`_ | `ComparisonExpr`_ |
+-------------------------+-------------------+-------------------+
| `Expr`_ ``==`` `Expr`_ | `EQExpr`_ | `EqualityTest`_ |
+-------------------------+-------------------+-------------------+
| `Expr`_ ``!=`` `Expr`_ | `NEExpr`_ | `EqualityTest`_ |
+-------------------------+-------------------+-------------------+
| `Expr`_ ``&`` `Expr`_ | `AndBitwiseExpr`_ | `BitwiseExpr`_ |
+-------------------------+-------------------+-------------------+
| `Expr`_ ``|`` `Expr`_ | `OrBitwiseExpr`_ | `BitwiseExpr`_ |
+-------------------------+-------------------+-------------------+
| `Expr`_ ``^`` `Expr`_ | `XorBitwiseExpr`_ | `BitwiseExpr`_ |
+-------------------------+-------------------+-------------------+
Assignment expressions
~~~~~~~~~~~~~~~~~~~~~~
All classes in this table are subclasses of `Assignment <https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$Assignment.html>`__.
+---------------------------+-----------------------+--------------+
| 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`` |
+---------------------------+-----------------------+--------------+
+--------------------------+----------------------+--------------+
| Expression syntax | CodeQL class | Superclasses |
+==========================+======================+==============+
| `Expr`_ ``=`` `Expr`_ | `AssignExpr`_ | |
+--------------------------+----------------------+--------------+
| `Expr`_ ``+=`` `Expr`_ | `AssignAddExpr`_ | `AssignOp`_ |
+--------------------------+----------------------+--------------+
| `Expr`_ ``-=`` `Expr`_ | `AssignSubExpr`_ | `AssignOp`_ |
+--------------------------+----------------------+--------------+
| `Expr`_ ``*=`` `Expr`_ | `AssignMulExpr`_ | `AssignOp`_ |
+--------------------------+----------------------+--------------+
| `Expr`_ ``/=`` `Expr`_ | `AssignDivExpr`_ | `AssignOp`_ |
+--------------------------+----------------------+--------------+
| `Expr`_ ``%=`` `Expr`_ | `AssignRemExpr`_ | `AssignOp`_ |
+--------------------------+----------------------+--------------+
| `Expr`_ ``&=`` `Expr`_ | `AssignAndExpr`_ | `AssignOp`_ |
+--------------------------+----------------------+--------------+
| `Expr`_ ``|=`` `Expr`_ | `AssignOrExpr`_ | `AssignOp`_ |
+--------------------------+----------------------+--------------+
| `Expr`_ ``^=`` `Expr`_ | `AssignXorExpr`_ | `AssignOp`_ |
+--------------------------+----------------------+--------------+
| `Expr`_ ``<<=`` `Expr`_ | `AssignLShiftExpr`_ | `AssignOp`_ |
+--------------------------+----------------------+--------------+
| `Expr`_ ``>>=`` `Expr`_ | `AssignRShiftExpr`_ | `AssignOp`_ |
+--------------------------+----------------------+--------------+
| `Expr`_ ``>>>=`` `Expr`_ | `AssignURShiftExpr`_ | `AssignOp`_ |
+--------------------------+----------------------+--------------+
Accesses
~~~~~~~~
@@ -248,7 +240,7 @@ Accesses
| ``? super Double`` | |
+--------------------------------------+-------------------------------------------------------------------------------------------------------------------------+
A ``VarAccess`` that refers to a field is a `FieldAccess <https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$FieldAccess.html>`__.
A `VarAccess <https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$VarAccess.html>`__ that refers to a field is a `FieldAccess <https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$FieldAccess.html>`__.
Miscellaneous
~~~~~~~~~~~~~
@@ -272,7 +264,7 @@ Miscellaneous
+------------------------------------------------------------------+ + +
| ``new int[] { 23, 42 }`` | | |
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------+
| ``{ 23, 42 }`` | `ArrayInit <https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$ArrayInit.html>`__ | can only appear as an initializer or as a child of an ``ArrayCreationExpr`` |
| ``{ 23, 42 }`` | `ArrayInit <https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$ArrayInit.html>`__ | can only appear as an initializer or as a child of an `ArrayCreationExpr`_ |
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------+
| ``@Annot(key=val)`` | `Annotation <https://help.semmle.com/qldoc/java/semmle/code/java/Annotation.qll/type.Annotation$Annotation.html>`__ |   |
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------+
@@ -281,4 +273,73 @@ Further reading
---------------
.. include:: ../../reusables/java-further-reading.rst
.. include:: ../../reusables/codeql-ref-tools-further-reading.rst
.. include:: ../../reusables/codeql-ref-tools-further-reading.rst
.. _Expr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$Expr.html
.. _Stmt: https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$Stmt.html
.. _VarAccess: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$VarAccess.html
.. _SwitchCase: https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$SwitchCase.html
.. _TypeAccess: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$TypeAccess.html
.. _Member: https://help.semmle.com/qldoc/java/semmle/code/java/Member.qll/type.Member$Member.html
.. _Literal: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$Literal.html
.. _ConditionalStmt: https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$ConditionalStmt.html
.. _LoopStmt: https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$LoopStmt.html
.. _JumpStmt: https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$JumpStmt.html
.. _TryStmt: https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$TryStmt.html
.. _SwitchStmt: https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$SwitchStmt.html
.. _BooleanLiteral: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$BooleanLiteral.html
.. _IntegerLiteral: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$IntegerLiteral.html
.. _LongLiteral: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$LongLiteral.html
.. _FloatingPointLiteral: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$FloatingPointLiteral.html
.. _DoubleLiteral: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$DoubleLiteral.html
.. _CharacterLiteral: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$CharacterLiteral.html
.. _StringLiteral: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$StringLiteral.html
.. _NullLiteral: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$NullLiteral.html
.. _PostIncExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$PostIncExpr.html
.. _PostDecExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$PostDecExpr.html
.. _PreIncExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$PreIncExpr.html
.. _PreDecExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$PreDecExpr.html
.. _BitNotExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$BitNotExpr.html
.. _MinusExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$MinusExpr.html
.. _PlusExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$PlusExpr.html
.. _LogNotExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$LogNotExpr.html
.. _UnaryAssignExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$UnaryAssignExpr.html
.. _BitwiseExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$BitwiseExpr.html
.. _LogicExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$LogicExpr.html
.. _MulExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$MulExpr.html
.. _DivExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$DivExpr.html
.. _RemExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$RemExpr.html
.. _AddExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$AddExpr.html
.. _SubExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$SubExpr.html
.. _LShiftExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$LShiftExpr.html
.. _RShiftExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$RShiftExpr.html
.. _URShiftExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$URShiftExpr.html
.. _AndLogicalExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$AndLogicalExpr.html
.. _OrLogicalExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$OrLogicalExpr.html
.. _LTExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$LTExpr.html
.. _GTExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$GTExpr.html
.. _LEExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$LEExpr.html
.. _GEExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$GEExpr.html
.. _EQExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$EQExpr.html
.. _NEExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$NEExpr.html
.. _AndBitwiseExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$AndBitwiseExpr.html
.. _OrBitwiseExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$OrBitwiseExpr.html
.. _XorBitwiseExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$XorBitwiseExpr.html
.. _LogicExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$LogicExpr.html
.. _ComparisonExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$ComparisonExpr.html
.. _EqualityTest: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$EqualityTest.html
.. _BitwiseExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$BitwiseExpr.html
.. _AssignExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$AssignExpr.html
.. _AssignAddExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$AssignAddExpr.html
.. _AssignSubExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$AssignSubExpr.html
.. _AssignMulExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$AssignMulExpr.html
.. _AssignDivExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$AssignDivExpr.html
.. _AssignRemExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$AssignRemExpr.html
.. _AssignAndExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$AssignAndExpr.html
.. _AssignOrExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$AssignOrExpr.html
.. _AssignXorExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$AssignXorExpr.html
.. _AssignLShiftExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$AssignLShiftExpr.html
.. _AssignRShiftExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$AssignRShiftExpr.html
.. _AssignURShiftExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$AssignURShiftExpr.html
.. _AssignOp: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$AssignOp.html
.. _ArrayCreationExpr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$ArrayCreationExpr.html