public interface SoyNode extends Node
The top level definition is the base node interface.
Important: Do not use outside of Soy code (treat as superpackage-private).
| Modifier and Type | Interface and Description |
|---|---|
static interface |
SoyNode.BlockCommandNode
A node that represents a Soy command that encloses a template block.
|
static interface |
SoyNode.BlockNode
A node that represents a template block.
|
static interface |
SoyNode.CommandNode
A node that represents a specific Soy command.
|
static interface |
SoyNode.ConditionalBlockNode
A node that represents a block of Soy code that is conditionally executed.
|
static interface |
SoyNode.ExprHolderNode
A node that holds some expressions in its fields/properties.
|
static class |
SoyNode.Kind
Enum of specific node kinds (corresponding to specific node types).
|
static interface |
SoyNode.LocalVarBlockNode
A node that adds a new local variable whose scope comprises the children of this code.
|
static interface |
SoyNode.LocalVarInlineNode
A node that adds a new local variable whose scope comprises the younger siblings of this node.
|
static interface |
SoyNode.LocalVarNode
A node that adds a new local variable.
|
static interface |
SoyNode.LoopNode
A node that represents a block of code that is executed in a loop.
|
static interface |
SoyNode.MsgBlockNode
A block node that can hold message content.
|
static interface |
SoyNode.MsgPlaceholderInitialNode
A node that can be the initial content (i.e.
|
static interface |
SoyNode.MsgSubstUnitNode
A substitution unit is any non-raw-text message part, since it will be replaced when the
message is rendered.
|
static interface |
SoyNode.ParentSoyNode<N extends SoyNode>
A node in a Soy parse tree that may be a parent.
|
static interface |
SoyNode.RenderUnitNode
A node that represents an independent unit of rendering.
|
static interface |
SoyNode.SplitLevelTopNode<N extends SoyNode>
A node that represents the top of a split-level structure in the parse tree.
|
static interface |
SoyNode.StandaloneNode
A node that can legally appear as the direct child of some block node (doesn't necessarily have
to be legal as the direct child of a template).
|
static interface |
SoyNode.StatementNode
A node that represents a specific Soy statement.
|
| Modifier and Type | Method and Description |
|---|---|
SoyNode |
copy(CopyState copyState)
Copies this node.
|
int |
getId()
Returns this node's id.
|
SoyNode.Kind |
getKind()
Returns this node's kind (corresponding to this node's specific type).
|
SoyNode.ParentSoyNode<?> |
getParent()
Gets this node's parent.
|
void |
setId(int id)
Sets this node's id.
|
couldHaveSyntaxVersionAtLeast, getNearestAncestor, getSourceLocation, getSyntaxVersionUpperBound, hasAncestor, maybeSetSyntaxVersionUpperBound, setParent, toSourceStringSoyNode.Kind getKind()
void setId(int id)
Important: The id should already be set during construction, so this method should only be used during cloning.
id - The new id for this node.int getId()
SoyNode.ParentSoyNode<?> getParent()
NodeSoyNode copy(CopyState copyState)
All copy() overrides should follow this contract:
{@literal @}Override public T copy(CopyState copyState) {
return new T(this, copyState);
}
TODO(lukes): The usecases for a copy method are few and far between. Making the AST nodes immutable (or at least unmodifiable) would be preferable to maintaining our copy() methods.
Don't clone nodes unless you know what you're doing. The Soy AST is not actually a tree (it contains back edges from variables to their definitions), and naively copying nodes can result in pointers into stale ASTs
The copied nodes will have the same ids as the original nodes. If you need to copy a
subtree with new ids assigned to the copied nodes, use SoytreeUtils.cloneWithNewIds(T, com.google.template.soy.base.internal.IdGenerator).