public final class ToplevelElements extends GoloElement<ToplevelElements> implements java.lang.Iterable<GoloElement<?>>
GoloElement.
This class is mainly used by top-level macros to return a collection of golo top-level elements, i.e. functions, structs, augments and so on, since a macro must return a unique GoloElement to inject in the Ir by replacing the macro call.
This element must never be present in a tree.
| Modifier and Type | Method and Description |
|---|---|
void |
accept(GoloIrVisitor visitor)
Accept the visitor.
|
ToplevelElements |
add(java.lang.Object element) |
java.util.List<GoloElement<?>> |
children()
Returns a list of all the direct children of this node.
|
static ToplevelElements |
fromIterable(java.lang.Iterable<java.lang.Object> elements)
Creates a top-level elements container.
|
boolean |
isEmpty() |
java.util.Iterator<GoloElement<?>> |
iterator() |
ToplevelElements |
map(FunctionReference fun)
Map a golo function on the contained elements.
|
static ToplevelElements |
of(java.lang.Object... elements)
Creates a top-level elements container.
|
void |
replaceElement(GoloElement<?> original,
GoloElement<?> newElement)
Replace a child.
|
protected ToplevelElements |
self() |
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, walkpublic static ToplevelElements of(java.lang.Object... elements)
Mainly used to return several nodes from a top-level macro.
If only a ToplevelElements instance is given, it is returned unchanged.
elements - the Golo Elements to add.ToplevelElements containing all the given elements.public static ToplevelElements fromIterable(java.lang.Iterable<java.lang.Object> elements)
Mainly used to return several nodes from a top-level macro.
protected ToplevelElements self()
self in class GoloElement<ToplevelElements>public ToplevelElements add(java.lang.Object element)
public boolean isEmpty()
public ToplevelElements map(FunctionReference fun) throws java.lang.Throwable
This can be used in top-level macros to apply the macro on a top-level from a previous macro application, for
instance when stacking decorator-like macros returning a ToplevelElements.
java.lang.Throwablepublic java.util.Iterator<GoloElement<?>> iterator()
iterator in interface java.lang.Iterable<GoloElement<?>>public java.util.List<GoloElement<?>> children()
GoloElementchildren in class GoloElement<ToplevelElements>public void replaceElement(GoloElement<?> original, GoloElement<?> newElement)
GoloElement
Replace original with newElement if original is a child of this node
and type matches.
replaceElement in class GoloElement<ToplevelElements>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 void accept(GoloIrVisitor visitor)
GoloElement
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<ToplevelElements>