public class ParseTreePattern
extends java.lang.Object
<ID> = <expr>; converted to a ParseTree by
ParseTreePatternMatcher.compile(String, int).| Modifier and Type | Field and Description |
|---|---|
private ParseTreePatternMatcher |
matcher
This is the backing field for
getMatcher(). |
private java.lang.String |
pattern
This is the backing field for
getPattern(). |
private int |
patternRuleIndex
This is the backing field for
getPatternRuleIndex(). |
private ParseTree |
patternTree
This is the backing field for
getPatternTree(). |
| Constructor and Description |
|---|
ParseTreePattern(ParseTreePatternMatcher matcher,
java.lang.String pattern,
int patternRuleIndex,
ParseTree patternTree)
Construct a new instance of the
ParseTreePattern class. |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<ParseTreeMatch> |
findAll(ParseTree tree,
java.lang.String xpath)
Find all nodes using XPath and then try to match those subtrees against
this tree pattern.
|
ParseTreePatternMatcher |
getMatcher()
Get the
ParseTreePatternMatcher which created this tree pattern. |
java.lang.String |
getPattern()
Get the tree pattern in concrete syntax form.
|
int |
getPatternRuleIndex()
Get the parser rule which serves as the outermost rule for the tree
pattern.
|
ParseTree |
getPatternTree()
Get the tree pattern as a
ParseTree. |
ParseTreeMatch |
match(ParseTree tree)
Match a specific parse tree against this tree pattern.
|
boolean |
matches(ParseTree tree)
Determine whether or not a parse tree matches this tree pattern.
|
private final int patternRuleIndex
getPatternRuleIndex().private final java.lang.String pattern
getPattern().private final ParseTree patternTree
getPatternTree().private final ParseTreePatternMatcher matcher
getMatcher().public ParseTreePattern(ParseTreePatternMatcher matcher, java.lang.String pattern, int patternRuleIndex, ParseTree patternTree)
ParseTreePattern class.matcher - The ParseTreePatternMatcher which created this
tree pattern.pattern - The tree pattern in concrete syntax form.patternRuleIndex - The parser rule which serves as the root of the
tree pattern.patternTree - The tree pattern in ParseTree form.public ParseTreeMatch match(ParseTree tree)
tree - The parse tree to match against this tree pattern.ParseTreeMatch object describing the result of the
match operation. The ParseTreeMatch.succeeded() method can be
used to determine whether or not the match was successful.public boolean matches(ParseTree tree)
tree - The parse tree to match against this tree pattern.true if tree is a match for the current tree
pattern; otherwise, false.public java.util.List<ParseTreeMatch> findAll(ParseTree tree, java.lang.String xpath)
tree - The ParseTree to match against this pattern.xpath - An expression matching the nodesParseTreeMatch objects describing the
successful matches. Unsuccessful matches are omitted from the result,
regardless of the reason for the failure.public ParseTreePatternMatcher getMatcher()
ParseTreePatternMatcher which created this tree pattern.ParseTreePatternMatcher which created this tree
pattern.public java.lang.String getPattern()
public int getPatternRuleIndex()
public ParseTree getPatternTree()
ParseTree. The rule and token tags from
the pattern are present in the parse tree as terminal nodes with a symbol
of type RuleTagToken or TokenTagToken.ParseTree.