public abstract class AbstractNode extends Object implements Node
Important: Do not use outside of Soy code (treat as superpackage-private).
| Modifier and Type | Field and Description |
|---|---|
protected static String |
SPACES
Just spaces.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractNode() |
protected |
AbstractNode(AbstractNode orig)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
abstract Node |
clone()
Copies this node.
|
boolean |
couldHaveSyntaxVersionAtLeast(SyntaxVersion syntaxVersionCutoff)
Returns false if we know that this node's syntax version must be lower than the given value.
|
<N extends Node> |
getNearestAncestor(Class<N> ancestorClass)
Finds and returns this node's nearest ancestor of the given type.
|
ParentNode<?> |
getParent()
Gets this node's parent.
|
SyntaxVersionBound |
getSyntaxVersionBound()
Returns a pair (syntaxVersion, reasonStr), where the first item is the lowest known upper bound
(exclusive!) for the syntax version of this node, and the second item is a user-friendly
explanation of the reason for the bound.
|
boolean |
hasAncestor(Class<? extends Node> ancestorClass)
Determines whether this node has an ancestor of the given type.
|
void |
maybeSetSyntaxVersionBound(SyntaxVersionBound newSyntaxVersionBound)
Records a newly discovered upper bound for the syntax version of this node.
|
void |
setParent(ParentNode<?> parent)
Sets this node's parent.
|
String |
toString() |
String |
toTreeString(int indent)
Builds a string that visually shows the subtree rooted at this node (for debugging).
|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetSourceLocation, toSourceStringprotected static final String SPACES
protected AbstractNode()
protected AbstractNode(AbstractNode orig)
orig - The node to copy.public void maybeSetSyntaxVersionBound(SyntaxVersionBound newSyntaxVersionBound)
NodemaybeSetSyntaxVersionBound in interface NodenewSyntaxVersionBound - A newly discovered upper bound (exclusive!) for the syntax version
of this node.@Nullable public SyntaxVersionBound getSyntaxVersionBound()
NodegetSyntaxVersionBound in interface Nodepublic boolean couldHaveSyntaxVersionAtLeast(SyntaxVersion syntaxVersionCutoff)
NodecouldHaveSyntaxVersionAtLeast in interface NodesyntaxVersionCutoff - The syntax version cutoff to check.public void setParent(ParentNode<?> parent)
Nodepublic ParentNode<?> getParent()
Nodepublic boolean hasAncestor(Class<? extends Node> ancestorClass)
NodehasAncestor in interface NodeancestorClass - The type of ancestor to look for.public <N extends Node> N getNearestAncestor(Class<N> ancestorClass)
NodegetNearestAncestor in interface NodeN - The type of ancestor to retrieve.ancestorClass - The class object for the type of ancestor to retrieve.public String toTreeString(int indent)
NodetoTreeString in interface Nodeindent - The indentation for each line of the tree string (usually pass 0).public abstract Node clone()
NodeAll clone() overrides should follow this contract:
{@literal @}Override public T clone() {
return new T(this);
}
NOTE: this means we do not ultimately delegate to Object.clone(), ever.
TODO(lukes): The usecases for a clone method are few and far between. Making the AST nodes immutable (or at least unmodifiable) would be preferable to maintaining our clone() methods.