com.google.template.soy.basetree
Interface Node
- All Known Subinterfaces:
- ExprNode, ExprNode.ConstantNode, ExprNode.OperatorNode, ExprNode.ParentExprNode, ExprNode.PrimitiveNode, ParentNode<N>, SoyNode, SoyNode.BlockCommandNode, SoyNode.BlockNode, SoyNode.CommandNode, SoyNode.ConditionalBlockNode, SoyNode.ExprHolderNode, SoyNode.LocalVarBlockNode, SoyNode.LocalVarInlineNode, SoyNode.LocalVarNode, SoyNode.LoopNode, SoyNode.MsgBlockNode, SoyNode.MsgPlaceholderInitialNode, SoyNode.ParentSoyNode<N>, SoyNode.RenderUnitNode, SoyNode.SplitLevelTopNode<N>, SoyNode.StandaloneNode, SoyNode.StatementNode
- All Known Implementing Classes:
- AbstractBlockCommandNode, AbstractBlockNode, AbstractCommandNode, AbstractExprNode, AbstractMsgNode, AbstractNode, AbstractOperatorNode, AbstractParentCommandNode, AbstractParentExprNode, AbstractParentNode, AbstractParentSoyNode, AbstractPrimitiveNode, AbstractSoyNode, BooleanNode, CallBasicNode, CallDelegateNode, CallNode, CallParamContentNode, CallParamNode, CallParamValueNode, CaseOrDefaultNode, CssNode, DataRefAccessExprNode, DataRefAccessIndexNode, DataRefAccessKeyNode, DataRefAccessNode, DataRefNode, DebuggerNode, ExprRootNode, FloatNode, ForeachIfemptyNode, ForeachNode, ForeachNonemptyNode, ForNode, FunctionNode, GlobalNode, GoogMsgNode, GoogMsgRefNode, IfCondNode, IfElseNode, IfNode, IntegerNode, LetContentNode, LetNode, LetValueNode, ListLiteralNode, LogNode, MapLiteralNode, MsgHtmlTagNode, MsgNode, MsgPlaceholderNode, MsgPluralCaseNode, MsgPluralDefaultNode, MsgPluralNode, MsgPluralRemainderNode, MsgSelectCaseNode, MsgSelectDefaultNode, MsgSelectNode, NullNode, OperatorNodes.AndOpNode, OperatorNodes.ConditionalOpNode, OperatorNodes.DivideByOpNode, OperatorNodes.EqualOpNode, OperatorNodes.GreaterThanOpNode, OperatorNodes.GreaterThanOrEqualOpNode, OperatorNodes.LessThanOpNode, OperatorNodes.LessThanOrEqualOpNode, OperatorNodes.MinusOpNode, OperatorNodes.ModOpNode, OperatorNodes.NegativeOpNode, OperatorNodes.NotEqualOpNode, OperatorNodes.NotOpNode, OperatorNodes.NullCoalescingOpNode, OperatorNodes.OrOpNode, OperatorNodes.PlusOpNode, OperatorNodes.TimesOpNode, PrintDirectiveNode, PrintNode, RawTextNode, SoyFileNode, SoyFileSetNode, StringNode, SwitchCaseNode, SwitchDefaultNode, SwitchNode, TemplateBasicNode, TemplateDelegateNode, TemplateNode, VarNode
public interface Node
This class defines the base interface for a node in the parse tree, as well as a number of
subinterfaces that extend the base interface in various aspects. Every concrete node implements
some subset of these interfaces.
The top level definition is the base node interface.
Important: Do not use outside of Soy code (treat as superpackage-private).
setParent
void setParent(ParentNode<?> parent)
- Sets this node's parent.
- Parameters:
parent - The parent node to set.
getParent
ParentNode<?> getParent()
- Gets this node's parent.
- Returns:
- This node's parent.
hasAncestor
boolean hasAncestor(Class<? extends Node> ancestorClass)
- Determines whether this node has an ancestor of the given type. The ancestor can be this node
(i.e. doesn't have to be a proper ancestor).
- Parameters:
ancestorClass - The type of ancestor to look for.
- Returns:
- True if this node has an ancestor of the given type.
getNearestAncestor
<N extends Node> N getNearestAncestor(Class<N> ancestorClass)
- Finds and returns this node's nearest ancestor of the given type. The ancestor can be this node
(i.e. doesn't have to be a proper ancestor).
- Type Parameters:
N - The type of ancestor to retrieve.- Parameters:
ancestorClass - The class object for the type of ancestor to retrieve.
- Returns:
- This node's nearest ancestor of the given type, or null if none.
toSourceString
String toSourceString()
- Builds a Soy source string that could be the source for this node. Note that this is not the
actual original source string, but a (sort of) canonical equivalent.
Note: Some nodes do not have a direct mapping to Soy source (such as nodes created during
some optimization passes). Thus this method may not always be supported.
- Returns:
- A Soy string that could be the source for this node.
- Throws:
UnsupportedOperationException - If this node does not directly map to Soy source.
toTreeString
String toTreeString(int indent)
- Builds a string that visually shows the subtree rooted at this node (for debugging).
Each line of the string will be indented by the given indentation amount. You should pass an
indentation of 0 unless this method is being called as part of building a larger tree string.
- Parameters:
indent - The indentation for each line of the tree string (usually pass 0).
- Returns:
- A string that visually shows the subtree rooted at this node.
clone
Node clone()
- Clones this node. The clone's parent pointer is set to null.
- Returns:
- A clone of this code.