public class Heuristics extends Object
For an example, see org.checkerframework.checker.interning.InterningVisitor
.
Modifier and Type | Class and Description |
---|---|
static class |
Heuristics.Matcher
A base class for tree-matching algorithms.
|
static class |
Heuristics.OfKind
match() returns true if called on a path whose leaf has the given kind (supplied at
object initialization). |
static class |
Heuristics.OrMatcher
match() returns true if any of the given matchers returns true. |
static class |
Heuristics.PreceededBy |
static class |
Heuristics.Within
match() returns true if called on a path, any element of which matches the given
matcher (supplied at object initialization). |
static class |
Heuristics.WithinTrueBranch
match() returns true if called on a path whose leaf is within the "then" clause of an
if whose conditon matches the matcher (supplied at object initialization). |
Constructor and Description |
---|
Heuristics() |
Modifier and Type | Method and Description |
---|---|
static boolean |
matchParents(TreePath path,
Tree.Kind... kinds)
Determines whether a tree has a particular set of direct parents, ignoring blocks and
parentheses.
|
public static boolean matchParents(TreePath path, Tree.Kind... kinds)
For example, to test whether an expression (specified by path
) is immediately
contained by an if statement which is immediately contained in a method, one would invoke:
matchParents(path, Kind.IF, Tree.Kind.METHOD)
path
- the path to matchkinds
- the tree kinds to match against, in ascending order starting from the desired kind
of the parent