public abstract class BaseTree extends java.lang.Object implements Tree
| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<java.lang.Object> |
children |
INVALID_NODE| Constructor and Description |
|---|
BaseTree() |
BaseTree(Tree node)
Create a new node from an existing node does nothing for BaseTree
as there are no fields other than the children list, which cannot
be copied as the children are not considered part of this node.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChild(Tree t)
Add t as child of this node.
|
void |
addChildren(java.util.List<? extends Tree> kids)
Add all elements of kids list as children of this node
|
protected java.util.List<java.lang.Object> |
createChildrenList()
Override in a subclass to change the impl of children list
|
java.lang.Object |
deleteChild(int i) |
void |
freshenParentAndChildIndexes()
Set the parent and child index values for all child of t
|
void |
freshenParentAndChildIndexes(int offset) |
void |
freshenParentAndChildIndexesDeeply() |
void |
freshenParentAndChildIndexesDeeply(int offset) |
Tree |
getAncestor(int ttype)
Walk upwards and get first ancestor with this token type.
|
java.util.List<? extends Tree> |
getAncestors()
Return a list of all ancestors of this node.
|
int |
getCharPositionInLine() |
Tree |
getChild(int i) |
int |
getChildCount() |
int |
getChildIndex()
BaseTree doesn't track child indexes.
|
java.util.List<? extends java.lang.Object> |
getChildren()
Get the children internal List; note that if you directly mess with
the list, do so at your own risk.
|
Tree |
getFirstChildWithType(int type) |
int |
getLine()
In case we don't have a token payload, what is the line for errors?
|
Tree |
getParent()
BaseTree doesn't track parent pointers.
|
boolean |
hasAncestor(int ttype)
Walk upwards looking for ancestor with this token type.
|
void |
insertChild(int i,
java.lang.Object t)
Insert child t at child position i (0..n-1) by shifting children
i+1..n-1 to the right one position.
|
boolean |
isNil()
Indicates the node is a nil node but may still have children, meaning
the tree is a flat list.
|
void |
replaceChildren(int startChildIndex,
int stopChildIndex,
java.lang.Object t)
Delete children from start to stop and replace with t even if t is
a list (nil-root tree).
|
void |
sanityCheckParentAndChildIndexes() |
void |
sanityCheckParentAndChildIndexes(Tree parent,
int i) |
void |
setChild(int i,
Tree t)
Set ith child (0..n-1) to t; t must be non-null and non-nil node
|
void |
setChildIndex(int index) |
void |
setParent(Tree t) |
abstract java.lang.String |
toString()
Override to say how a node (not a tree) should look as text
|
java.lang.String |
toStringTree()
Print out a whole tree not just a node
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdupNode, getText, getTokenStartIndex, getTokenStopIndex, getType, setTokenStartIndex, setTokenStopIndexpublic BaseTree()
public BaseTree(Tree node)
public java.util.List<? extends java.lang.Object> getChildren()
public Tree getFirstChildWithType(int type)
public int getChildCount()
getChildCount in interface Treepublic void addChild(Tree t)
public void addChildren(java.util.List<? extends Tree> kids)
public void setChild(int i,
Tree t)
Treepublic void insertChild(int i,
java.lang.Object t)
public java.lang.Object deleteChild(int i)
deleteChild in interface Treepublic void replaceChildren(int startChildIndex,
int stopChildIndex,
java.lang.Object t)
replaceChildren in interface Treeprotected java.util.List<java.lang.Object> createChildrenList()
public boolean isNil()
Treepublic void freshenParentAndChildIndexes()
freshenParentAndChildIndexes in interface Treepublic void freshenParentAndChildIndexes(int offset)
public void freshenParentAndChildIndexesDeeply()
public void freshenParentAndChildIndexesDeeply(int offset)
public void sanityCheckParentAndChildIndexes()
public void sanityCheckParentAndChildIndexes(Tree parent, int i)
public int getChildIndex()
getChildIndex in interface Treepublic void setChildIndex(int index)
setChildIndex in interface Treepublic Tree getParent()
public boolean hasAncestor(int ttype)
hasAncestor in interface Treepublic Tree getAncestor(int ttype)
getAncestor in interface Treepublic java.util.List<? extends Tree> getAncestors()
getAncestors in interface Treepublic java.lang.String toStringTree()
toStringTree in interface Treepublic int getLine()
Treepublic int getCharPositionInLine()
getCharPositionInLine in interface Tree