public final class MethodInvocation extends AbstractInvocation<MethodInvocation>
For instance golo code as
foo()?: bar(42)
can be generated with:
invoke("bar").nullSafe().withArgs(42).on(call("foo"))
usesNamedArguments| Modifier and Type | Method and Description |
|---|---|
void |
accept(GoloIrVisitor visitor)
Accept the visitor.
|
static MethodInvocation |
invoke(java.lang.String name) |
boolean |
isNullSafeGuarded()
Checks if this invocation is null-safe.
|
MethodInvocation |
nullSafe()
Defines the invocation as null-safe.
|
MethodInvocation |
nullSafe(boolean v)
Defines if the invocation is null-safe or not.
|
BinaryOperation |
on(java.lang.Object target)
Defines the receiver of the invocation.
|
protected MethodInvocation |
self() |
MethodInvocation |
withArgs(java.lang.Object... args)
Defines the values of the arguments for this invocation.
|
children, getArguments, getArity, getFunctionName, getModuleName, getName, getPackageAndClass, namedArgumentsComplete, replaceElement, setPackageAndClass, usesNamedArguments, withNamedArgumentscall, clearDeclarations, declarations, hasLocalDeclarations, of, withancestor, 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, walkpublic static MethodInvocation invoke(java.lang.String name)
protected MethodInvocation self()
self in class GoloElement<MethodInvocation>public boolean isNullSafeGuarded()
I.e. if called with an elvis operator syntax (obj?: method())
public MethodInvocation nullSafe(boolean v)
public MethodInvocation nullSafe()
public BinaryOperation on(java.lang.Object target)
public MethodInvocation withArgs(java.lang.Object... args)
This is a builder method.
This methods appends the arguments to the existing ones, so that it can be called multiple times to create the invocation incrementally. On the other hand, it is not idempotent.
Calls AbstractInvocation.withNamedArguments() if needed.
withArgs in class AbstractInvocation<MethodInvocation>args - the arguments of the invocation. An argument can be any GoloElement, or are converted with
ExpressionStatement.of(Object) otherwise, so that strings and primitives are automatically wrapped in a
ConstantStatement.AbstractInvocation.withNamedArguments(),
ExpressionStatement.of(Object)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<MethodInvocation>