public class Trees
extends java.lang.Object
| Modifier | Constructor and Description |
|---|---|
private |
Trees() |
| Modifier and Type | Method and Description |
|---|---|
static void |
_findAllNodes(ParseTree t,
int index,
boolean findTokens,
java.util.List<? super ParseTree> nodes) |
static java.util.List<ParseTree> |
descendants(ParseTree t)
Deprecated.
|
static java.util.List<ParseTree> |
findAllNodes(ParseTree t,
int index,
boolean findTokens) |
static java.util.Collection<ParseTree> |
findAllRuleNodes(ParseTree t,
int ruleIndex) |
static java.util.Collection<ParseTree> |
findAllTokenNodes(ParseTree t,
int ttype) |
static Tree |
findNodeSuchThat(Tree t,
Predicate<Tree> pred)
Return first node satisfying the pred
|
static java.util.List<? extends Tree> |
getAncestors(Tree t)
Return a list of all ancestors of this node.
|
static java.util.List<Tree> |
getChildren(Tree t)
Return ordered list of all children of this node
|
static java.util.List<ParseTree> |
getDescendants(ParseTree t)
Get all descendents; includes t itself.
|
static java.lang.String |
getNodeText(Tree t,
java.util.List<java.lang.String> ruleNames) |
static java.lang.String |
getNodeText(Tree t,
Parser recog) |
static ParserRuleContext |
getRootOfSubtreeEnclosingRegion(ParseTree t,
int startTokenIndex,
int stopTokenIndex)
Find smallest subtree of t enclosing range startTokenIndex..stopTokenIndex
inclusively using postorder traversal.
|
static boolean |
isAncestorOf(Tree t,
Tree u)
Return true if t is u's parent or a node on path to root from u.
|
static void |
stripChildrenOutOfRange(ParserRuleContext t,
ParserRuleContext root,
int startIndex,
int stopIndex)
Replace any subtree siblings of root that are completely to left
or right of lookahead range with a CommonToken(Token.INVALID_TYPE,"...")
node.
|
static java.lang.String |
toStringTree(Tree t)
Print out a whole tree in LISP form.
|
static java.lang.String |
toStringTree(Tree t,
java.util.List<java.lang.String> ruleNames)
Print out a whole tree in LISP form.
|
static java.lang.String |
toStringTree(Tree t,
Parser recog)
Print out a whole tree in LISP form.
|
public static java.lang.String toStringTree(Tree t)
getNodeText(org.antlr.v4.runtime.tree.Tree, org.antlr.v4.runtime.Parser) is used on the
node payloads to get the text for the nodes. Detect
parse trees and extract data appropriately.public static java.lang.String toStringTree(Tree t, Parser recog)
getNodeText(org.antlr.v4.runtime.tree.Tree, org.antlr.v4.runtime.Parser) is used on the
node payloads to get the text for the nodes. Detect
parse trees and extract data appropriately.public static java.lang.String toStringTree(Tree t, java.util.List<java.lang.String> ruleNames)
getNodeText(org.antlr.v4.runtime.tree.Tree, org.antlr.v4.runtime.Parser) is used on the
node payloads to get the text for the nodes.public static java.lang.String getNodeText(Tree t, java.util.List<java.lang.String> ruleNames)
public static java.util.List<Tree> getChildren(Tree t)
public static java.util.List<? extends Tree> getAncestors(Tree t)
public static boolean isAncestorOf(Tree t, Tree u)
public static java.util.Collection<ParseTree> findAllTokenNodes(ParseTree t, int ttype)
public static java.util.Collection<ParseTree> findAllRuleNodes(ParseTree t, int ruleIndex)
public static java.util.List<ParseTree> findAllNodes(ParseTree t, int index, boolean findTokens)
public static void _findAllNodes(ParseTree t, int index, boolean findTokens, java.util.List<? super ParseTree> nodes)
public static java.util.List<ParseTree> getDescendants(ParseTree t)
public static ParserRuleContext getRootOfSubtreeEnclosingRegion(ParseTree t, int startTokenIndex, int stopTokenIndex)
public static void stripChildrenOutOfRange(ParserRuleContext t, ParserRuleContext root, int startIndex, int stopIndex)