Module java

Module java 

Source
Expand description

Java code syntax

Java syntax elements.

Note that no checking exists to make sure the elements are used correctly, i.e. the correct combination of structs. Instead, the library user is expected to have basic knowledge of how Java syntax is composed, and to combine the structs in this module likewise.

Structs§

Array
An array of another type. Renders as Component[]
AssertStmt
An assertion. Renders as assert Assert; with a new line at the end
AssignExpr
An assignation, as an expression. Renders as Variable = Expr. In Java, an assignation expression has the same type and value as the assigned value.
AssignStmt
An assignation. This statement includes the semicolon and a new line.
Block
An unlabeled block. This can be used in many contexts, including merely organizing the code.
ClassDef
Declares a class.
ConstructorCall
Calls a constructor with a name and arguments. Renders as new Name(Arg1, Arg2, Arg3, ...)
ConstructorDef
Defines a constructor
DeclareParam
A function parameter, constructor parameter, or record component parameter.
DeclareVarStmt
Declares a new variable. Renders as Type Expr; with a new line at the end The expression can be either the variable name or an AssignExpr.
Else
Represents “else” syntactically. Renders as Before else After.
EnhancedFor
An enhanced for loop in the style for (VarName : Iter) { Body }. All fields of this struct must be writable.
Extends
The “extends” keyword. Renders as Expr extends Super.
FunctionCall
Calls a function with a name and arguments. Renders as Name(Arg1, Arg2, Arg3, ...)
FunctionDef
Defines a function
IfBlock
An if block. The condition and body must both be writable.
Implements
The “implements” keyword. Renders as Expr implements Iface1, Iface2, Iface3, .... The interfaces must be a sequence. If it is empty, then only Expr will be rendered.
InterfaceDef
Declares an interface
MemberAccess
Accesses a field or calls a method by name. Renders as Owner.Member.
Parameterized
A type argument-parameterized declaration. Renders as Name<TypeArgs>.
ReturnStmt
A return statement. Renders as return Expr; with a new line at the end.
Stmt
A standalone statement. Renders the expression and adds a semicolon and a new line.
TraditionalFor
A traditional for loop in the style for (Init; Predicate; Update) { Body }. All the fields of this struct must be writable. For example:
WithInference
Applies diamond inference to the construction of a type. Renders as Name<>.

Enums§

Modifier
A single modifier keyword