public abstract class GoloAssignment<T extends GoloAssignment<T>> extends GoloStatement<T> implements ReferencesHolder
Modifier and Type | Method and Description |
---|---|
T |
as(java.lang.Object expr)
Defines the value to be assigned.
|
java.util.List<GoloElement<?>> |
children()
Returns a list of all the direct children of this node.
|
T |
declaring()
Makes this assignment a declaring one.
|
T |
declaring(boolean isDeclaring)
Defines if this assignment is a declaring one.
|
ExpressionStatement<?> |
expression() |
LocalReference[] |
getDeclaringReferences()
Returns only the declaring references.
|
abstract boolean |
isConstant()
Checks if this assignment is constant.
|
boolean |
isDeclaring()
Checks if this assignment is a declaring one.
|
protected void |
replaceElement(GoloElement<?> original,
GoloElement<?> newElement)
Replace a child.
|
abstract T |
to(java.lang.Object... refs)
Defines the references to which assign the expression.
|
abstract T |
variable()
Makes this assignment variable.
|
of
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getReferences, getReferencesCount
public final boolean isDeclaring()
declaring()
public final T declaring(boolean isDeclaring)
let
or var
assignment. An assignment to a previously defined
mutable variable (one declared with var
) is not a declaring assignment.
This is a builder method.
isDeclaring
- whether the assignment is declaring.public final T declaring()
Same as declaring(true)
.
public abstract T variable()
LocalReference.variable()
public abstract boolean isConstant()
LocalReference.isConstant()
public final ExpressionStatement<?> expression()
public final T as(java.lang.Object expr)
This is a builder method.
expr
- the ExpressionStatement
to assign or an object that can be converted into an expressionExpressionStatement.of(Object)
public abstract T to(java.lang.Object... refs)
This is a builder method.
For instance, code like:
foo = 42
can be generated by:
assign(constant(42)).to(localRef("foo"))
or using implicit conversions:
assign(42).to("foo")
refs
- the LocalReference
s to assign topublic LocalReference[] getDeclaringReferences()
getDeclaringReferences
in interface ReferencesHolder
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 GoloAssignment<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)
public java.util.List<GoloElement<?>> children()
children
in class GoloElement<T extends GoloAssignment<T>>