public class ClosureReference extends ExpressionStatement<ClosureReference> implements BlockContainer<ClosureReference>
A closure reference is a wrapper around a golo function, to represent a closure or a lambda. For instance, the golo code:
foo(|x| -> x + 1)
The argument of the call to foo
is a ClosureReference
wrapping the actual GoloFunction
To ease manipulating this node, it delegate most of its methods to the wrapped target function.
Modifier and Type | Method and Description |
---|---|
void |
accept(GoloIrVisitor visitor)
Accept the visitor.
|
ClosureReference |
block(java.lang.Object block)
Delegates on the wrapped target.
|
ClosureReference |
body(java.lang.Object... statements)
Delegates on the wrapped target.
|
java.util.List<GoloElement<?>> |
children()
Returns a list of all the direct children of this node.
|
Block |
getBlock()
Delegates on the wrapped target.
|
java.util.Collection<java.lang.String> |
getCapturedReferenceNames()
Delegates on the wrapped target.
|
GoloFunction |
getTarget() |
boolean |
hasCapturedReferences()
Checks if this reference has closed variables.
|
boolean |
isVarargs()
Delegates on the wrapped target.
|
protected void |
replaceElement(GoloElement<?> original,
GoloElement<?> newElement)
Replace a child.
|
ClosureReference |
returns(java.lang.Object expression)
Delegates on the wrapped target.
|
protected ClosureReference |
self() |
java.lang.String |
toString() |
ClosureReference |
varargs()
Delegates on the wrapped target.
|
ClosureReference |
varargs(boolean v) |
void |
walk(GoloIrVisitor visitor)
Walk the visitor through this node children.
|
ClosureReference |
withParameters(java.util.Collection<java.lang.String> paramNames)
Delegates on the wrapped target.
|
call, clearDeclarations, declarations, hasLocalDeclarations, of, 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
protected ClosureReference self()
self
in class GoloElement<ClosureReference>
public GoloFunction getTarget()
public java.util.Collection<java.lang.String> getCapturedReferenceNames()
public boolean hasCapturedReferences()
public ClosureReference body(java.lang.Object... statements)
body
in interface BlockContainer<ClosureReference>
statements
- the statements to execute.BlockContainer.body(Object...)
public ClosureReference block(java.lang.Object block)
block
in interface BlockContainer<ClosureReference>
block
- an object that can be converted into a Block
GoloFunction.block(Object)
public Block getBlock()
getBlock
in interface BlockContainer<ClosureReference>
GoloFunction.getBlock()
public ClosureReference returns(java.lang.Object expression)
GoloFunction.returns(Object)
public ClosureReference varargs()
GoloFunction.varargs()
public ClosureReference varargs(boolean v)
public boolean isVarargs()
GoloFunction.isVarargs()
public ClosureReference withParameters(java.util.Collection<java.lang.String> paramNames)
GoloFunction.withParameters(Collection)
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<ClosureReference>
public void walk(GoloIrVisitor visitor)
walk
in class GoloElement<ClosureReference>
public java.util.List<GoloElement<?>> children()
children
in class GoloElement<ClosureReference>
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<ClosureReference>
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)
public java.lang.String toString()
toString
in class java.lang.Object