|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.hibernate.hql.ast.util.ASTUtil
public final class ASTUtil
Provides utility methods for AST traversal and manipulation.
Nested Class Summary | |
---|---|
static interface |
ASTUtil.FilterPredicate
Filters nodes out of a tree. |
static class |
ASTUtil.IncludePredicate
A predicate that uses inclusion, rather than exclusion semantics. |
Method Summary | |
---|---|
static void |
appendSibling(antlr.collections.AST n,
antlr.collections.AST s)
|
static java.util.List |
collectChildren(antlr.collections.AST root,
ASTUtil.FilterPredicate predicate)
|
static antlr.collections.AST |
create(antlr.ASTFactory astFactory,
int type,
java.lang.String text)
Deprecated. silly |
static antlr.collections.AST |
createBinarySubtree(antlr.ASTFactory factory,
int parentType,
java.lang.String parentText,
antlr.collections.AST child1,
antlr.collections.AST child2)
Creates a 'binary operator' subtree, given the information about the parent and the two child nodex. |
static antlr.collections.AST |
createParent(antlr.ASTFactory factory,
int parentType,
java.lang.String parentText,
antlr.collections.AST child)
Creates a single parent of the specified child (i.e. |
static antlr.collections.AST |
createSibling(antlr.ASTFactory astFactory,
int type,
java.lang.String text,
antlr.collections.AST prevSibling)
Creates a single node AST as a sibling of the passed prevSibling, taking care to reorganize the tree correctly to account for this newly created node. |
static antlr.collections.AST |
createTree(antlr.ASTFactory factory,
antlr.collections.AST[] nestedChildren)
|
static antlr.collections.AST |
findPreviousSibling(antlr.collections.AST parent,
antlr.collections.AST child)
Find the previous sibling in the parent for the given child. |
static antlr.collections.AST |
findTypeInChildren(antlr.collections.AST parent,
int type)
Finds the first node of the specified type in the chain of children. |
static java.util.Map |
generateTokenNameCache(java.lang.Class tokenTypeInterface)
Method to generate a map of token type names, keyed by their token type values. |
static java.lang.String |
getConstantName(java.lang.Class owner,
int value)
Deprecated. Use #getTokenTypeName instead |
static java.lang.String |
getDebugString(antlr.collections.AST n)
Returns the 'list' representation with some brackets around it for debugging. |
static antlr.collections.AST |
getLastChild(antlr.collections.AST n)
Returns the last direct child of 'n'. |
static java.lang.String |
getPathText(antlr.collections.AST n)
|
static java.lang.String |
getTokenTypeName(java.lang.Class tokenTypeInterface,
int tokenType)
Intended to retrieve the name of an AST token type based on the token type interface. |
static boolean |
hasExactlyOneChild(antlr.collections.AST n)
|
static void |
insertChild(antlr.collections.AST parent,
antlr.collections.AST child)
Inserts the child as the first child of the parent, all other children are shifted over to the 'right'. |
static antlr.collections.AST |
insertSibling(antlr.collections.AST node,
antlr.collections.AST prevSibling)
Inserts a node into a child subtree as a particularly positioned sibling taking care to properly reorganize the tree to account for this new addition. |
static boolean |
isSubtreeChild(antlr.collections.AST fixture,
antlr.collections.AST test)
Determine if a given node (test) is contained anywhere in the subtree of another given node (fixture). |
static void |
makeSiblingOfParent(antlr.collections.AST parent,
antlr.collections.AST child)
Makes the child node a sibling of the parent, reconnecting all siblings. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static antlr.collections.AST create(antlr.ASTFactory astFactory, int type, java.lang.String text)
astFactory
- The factory.type
- The node type.text
- The node text.
public static antlr.collections.AST createSibling(antlr.ASTFactory astFactory, int type, java.lang.String text, antlr.collections.AST prevSibling)
astFactory
- The factory.type
- The node type.text
- The node text.prevSibling
- The previous sibling.
public static antlr.collections.AST insertSibling(antlr.collections.AST node, antlr.collections.AST prevSibling)
node
- The node to insertprevSibling
- The previous node at the sibling position
where we want this node inserted.
public static antlr.collections.AST createBinarySubtree(antlr.ASTFactory factory, int parentType, java.lang.String parentText, antlr.collections.AST child1, antlr.collections.AST child2)
factory
- The AST factory.parentType
- The type of the parent node.parentText
- The text of the parent node.child1
- The first child.child2
- The second child.
public static antlr.collections.AST createParent(antlr.ASTFactory factory, int parentType, java.lang.String parentText, antlr.collections.AST child)
factory
- The AST factory.parentType
- The type of the parent node.parentText
- The text of the parent node.child
- The child.
public static antlr.collections.AST createTree(antlr.ASTFactory factory, antlr.collections.AST[] nestedChildren)
public static boolean isSubtreeChild(antlr.collections.AST fixture, antlr.collections.AST test)
fixture
- The node against which to testto be checked for children.test
- The node to be tested as being a subtree child of the parent.
public static antlr.collections.AST findTypeInChildren(antlr.collections.AST parent, int type)
parent
- The parenttype
- The type to find.
public static antlr.collections.AST getLastChild(antlr.collections.AST n)
n
- The parent
public static java.lang.String getDebugString(antlr.collections.AST n)
n
- The tree.
public static antlr.collections.AST findPreviousSibling(antlr.collections.AST parent, antlr.collections.AST child)
parent
- the parent nodechild
- the child to find the previous sibling of
public static void makeSiblingOfParent(antlr.collections.AST parent, antlr.collections.AST child)
parent
- the parentchild
- the childpublic static java.lang.String getPathText(antlr.collections.AST n)
public static boolean hasExactlyOneChild(antlr.collections.AST n)
public static void appendSibling(antlr.collections.AST n, antlr.collections.AST s)
public static void insertChild(antlr.collections.AST parent, antlr.collections.AST child)
parent
- the parentchild
- the new first childpublic static java.util.List collectChildren(antlr.collections.AST root, ASTUtil.FilterPredicate predicate)
public static java.util.Map generateTokenNameCache(java.lang.Class tokenTypeInterface)
tokenTypeInterface
- The *TokenTypes interface (or implementor of said interface).
public static java.lang.String getConstantName(java.lang.Class owner, int value)
owner
- The class which defines the constantvalue
- The value of the constant.
public static java.lang.String getTokenTypeName(java.lang.Class tokenTypeInterface, int tokenType)
tokenTypeInterface
- The *TokenTypes interface (or one of its implementors).tokenType
- The token type value.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |