public abstract class AbstractInvocation<T extends AbstractInvocation<T>> extends ExpressionStatement<T>
Used to represent regular function call, method invocation, and macro call.
Note that the called object is only refereed by its name and not an IR node, since the linkage is done at runtime. There is no guaranty that such an object exists.
Modifier and Type | Field and Description |
---|---|
protected boolean |
usesNamedArguments |
Modifier and Type | Method and Description |
---|---|
java.util.List<GoloElement<?>> |
children()
Returns a list of all the direct children of this node.
|
java.util.List<GoloElement<?>> |
getArguments() |
int |
getArity()
Returns the number or arguments of this invocation.
|
java.lang.String |
getFunctionName()
Returns the object part of the called object name.
|
java.lang.String |
getModuleName()
Returns the module part of the called object name.
|
java.lang.String |
getName()
Returns the fully qualified name of the called object.
|
PackageAndClass |
getPackageAndClass() |
boolean |
namedArgumentsComplete() |
protected void |
replaceElement(GoloElement<?> original,
GoloElement<?> newElement)
Replace a child.
|
void |
setPackageAndClass(PackageAndClass name) |
boolean |
usesNamedArguments()
Checks if this call uses the named arguments syntax.
|
T |
withArgs(java.lang.Object... arguments)
Defines the values of the arguments for this invocation.
|
T |
withNamedArguments()
Mark the invocation as using names arguments syntax.
|
call, clearDeclarations, declarations, hasLocalDeclarations, of, with
accept, 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, self, walk
protected boolean usesNamedArguments
public java.lang.String getName()
public java.lang.String getModuleName()
public java.lang.String getFunctionName()
public void setPackageAndClass(PackageAndClass name)
public PackageAndClass getPackageAndClass()
public T withArgs(java.lang.Object... arguments)
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 withNamedArguments()
if needed.
arguments
- 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
.withNamedArguments()
,
ExpressionStatement.of(Object)
public java.util.List<GoloElement<?>> getArguments()
public int getArity()
It can be different of called object number of parameters if it is a vararg one.
Since the call is resolved at runtime, there is no guaranty that these two numbers match.
public boolean usesNamedArguments()
See the Golo Guide on Named Parameters
public boolean namedArgumentsComplete()
public T withNamedArguments()
This is a builder method.
This method should not need to be called directly since the withArgs(Object...)
one checks its argument
and call this one if needed.
withArgs(Object...)
public java.util.List<GoloElement<?>> children()
children
in class GoloElement<T extends AbstractInvocation<T>>
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<T extends AbstractInvocation<T>>
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)