public final class CollectionComprehension extends ExpressionStatement<CollectionComprehension>
Such as:
list[2*x + y foreach x in someIterable for (var y=0, y < 5, y = y + 1)]
CollectionLiteral.Type
Modifier and Type | Method and Description |
---|---|
void |
accept(GoloIrVisitor visitor)
Accept the visitor.
|
java.util.List<GoloElement<?>> |
children()
Returns a list of all the direct children of this node.
|
static CollectionComprehension |
create(java.lang.Object type,
java.lang.Object expression,
java.lang.Object... loops)
Complete collection comprehension creation.
|
ExpressionStatement<?> |
expression() |
CollectionComprehension |
expression(java.lang.Object expression)
Defines the expression of the comprehension.
|
CollectionLiteral.Type |
getMutableType() |
CollectionLiteral.Type |
getType() |
CollectionComprehension |
loop(java.lang.Object loop)
Adds a loop instruction to this comprehension.
|
java.util.List<GoloStatement<?>> |
loops() |
static CollectionComprehension |
of(java.lang.Object type)
Creates a collection comprehension of the given type.
|
protected void |
replaceElement(GoloElement<?> original,
GoloElement<?> newElement)
Replace a child.
|
protected CollectionComprehension |
self() |
call, clearDeclarations, declarations, hasLocalDeclarations, with
ancestor, ancestor, ancestorOfType, cantConvert, cantReplace, cantReplace, children, children, descendants, descendants, descendants, documentation, documentation, doesNotContain, enclosingModule, getLocalReferenceTable, hasParent, hasPosition, makeParentOf, metadata, metadata, next, next, next, ofAST, parent, positionInSourceCode, positionInSourceCode, previous, previous, previous, replaceInParentBy, walk
public static CollectionComprehension of(java.lang.Object type)
public static CollectionComprehension create(java.lang.Object type, java.lang.Object expression, java.lang.Object... loops)
protected CollectionComprehension self()
self
in class GoloElement<CollectionComprehension>
public CollectionComprehension expression(java.lang.Object expression)
2*x + y
in the previous example.public CollectionComprehension loop(java.lang.Object loop)
The object to add is a loop-like expression, foreach x in someIterable
and
for (var y=0, y < 5, y = y + 1)
in the previous example.
loop
- a ForEachLoopStatement
or a LoopStatement
.public ExpressionStatement<?> expression()
public java.util.List<GoloStatement<?>> loops()
public CollectionLiteral.Type getType()
public CollectionLiteral.Type getMutableType()
public void accept(GoloIrVisitor visitor)
This method should only call the visitor visitXXXX
method.
The children of this node will be visited by the
GoloElement.walk(GoloIrVisitor)
method.
accept
in class GoloElement<CollectionComprehension>
public java.util.List<GoloElement<?>> children()
children
in class GoloElement<CollectionComprehension>
protected void replaceElement(GoloElement<?> original, GoloElement<?> newElement)
Replace original
with newElement
if original
is a child of this node
and type matches.
replaceElement
in class GoloElement<CollectionComprehension>
original
- the original value to replace. Must be a child of this nodenewElement
- the element to replace with. Type must match.GoloElement.cantReplace()
,
GoloElement.cantReplace(GoloElement, GoloElement)
,
GoloElement.doesNotContain(GoloElement)
,
GoloElement.cantConvert(String, Object)