public final class Decorator extends GoloElement<Decorator>
For instance in:
@decorator
function foo = |x| -> x
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.
|
Decorator |
constant() |
Decorator |
constant(boolean constant) |
ExpressionStatement<?> |
expression() |
boolean |
isConstant() |
static Decorator |
of(java.lang.Object expr)
Create a function decorator from the given expression.
|
protected void |
replaceElement(GoloElement<?> original,
GoloElement<?> newElement)
Replace a child.
|
protected Decorator |
self() |
java.lang.String |
toString() |
ExpressionStatement<?> |
wrapExpression(ExpressionStatement<?> expression) |
ancestor, ancestor, ancestorOfType, cantConvert, cantReplace, cantReplace, children, children, descendants, descendants, descendants, documentation, documentation, doesNotContain, enclosingModule, getLocalReferenceTable, hasParent, hasPosition, inheritedMetadata, makeParentOf, metadata, metadata, next, next, next, ofAST, parent, positionInSourceCode, positionInSourceCode, previous, previous, previous, replaceInParentBy, walk
public static Decorator of(java.lang.Object expr)
Since this function is implicitly called by GoloFunction.decoratedWith(Object...)
, it should not be
necessary to use it directly. For instance:
function("foo").returns(constant(42)).decoratedWith(ReferenceLookup.of("deco"))
creates
@deco
function foo = -> 42
Valid expressions are:
Decorator
)
ReferenceLookup
) as in @deco
FunctionInvocation
) as in @deco(42)
ClosureReference
) as in @(|f| -> |x| -> f(x) + 42)
@deco("answer")(42)
expr
- the expression representing the decorator or any element that can be converted into a valid
ExpressionStatement
ExpressionStatement.of(Object)
protected Decorator self()
self
in class GoloElement<Decorator>
public ExpressionStatement<?> expression()
public boolean isConstant()
public ExpressionStatement<?> wrapExpression(ExpressionStatement<?> expression)
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<Decorator>
public java.util.List<GoloElement<?>> children()
children
in class GoloElement<Decorator>
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<Decorator>
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