A predicate DSL for matching javac AST nodes. This allows concise, readable declarative code for describing a match, by composing generic-type-safe matchers on the inspected AST subtree.
Interface Summary Interface Description Matcher<T extends com.sun.source.tree.Tree>Define a predicate on a
Tree, which also accesses the state of AST traversal.
MultiMatcher<T extends com.sun.source.tree.Tree,N extends com.sun.source.tree.Tree>An matcher that applies a single matcher across multiple tree nodes. Suppressible
Class Summary Class Description AbstractTypeMatcher<T extends com.sun.source.tree.Tree>Base class for type matchers. AnnotationDoesNotHaveArgumentMatches an annotation that does not have a particular argument, possibly because the default value is being used. AnnotationHasArgumentWithValue AnnotationMatcher<T extends com.sun.source.tree.Tree>Matches if the given annotation matcher matches all of or any of the annotations on the tree node. AnnotationMatcherUtilsUtilities for matching annotations. AnnotationType AssertsMatches assert statements which have a condition expression matched by the given matcher. ChildMultiMatcher<T extends com.sun.source.tree.Tree,N extends com.sun.source.tree.Tree>A
MultiMatcherthat applies a matcher across multiple children of a single ancestor node.
CompileTimeConstantExpressionMatcherA matcher for compile-time-constant expressions. CompoundAssignmentMatcher for a compound-assignment operator expression. ConstructorOfClassApplies the given matcher to the constructor(s) of the given class. ContainsA matcher that recursively inspects a tree, applying the given matcher to all levels of each tree and returning
trueif any match is found.
DescriptionSimple data object containing the information captured about an AST match. Description.BuilderBuilder for
EnclosingAdapt matchers to match against a parent node of a given type. Enclosing.Block<T extends com.sun.source.tree.Tree> Enclosing.BlockOrCase<T extends com.sun.source.tree.Tree> Enclosing.Class<T extends com.sun.source.tree.Tree> Enclosing.Method<T extends com.sun.source.tree.Tree> FieldMatchersStatic utility methods for creating
Matchers for detecting references to fields.
HasArgumentsMatches if the given matcher matches all of/any of the parameters to this method. HasIdentifierMatches if the given matcher matches all of the identifiers under this syntax tree. InjectMatchersUtility constants and matchers related to dependency injection. IsSameType<T extends com.sun.source.tree.Tree>Matches an AST node if its erased type is the same as the given type, e.g. IsSubtypeOf<T extends com.sun.source.tree.Tree> JUnitMatchersMatchers for code patterns which appear to be JUnit-based tests. MatchersStatic factory methods which make the DSL read more fluently. MethodHasParametersMatches if the given matcher matches all of/any of the parameters to this method. MethodInvocationMatches a method invocation based on a matcher for the method select (receiver + method identifier) and one for the arguments. MethodInvocationArgumentApplies an Expression matcher to an argument of a MethodInvocation by position. MethodInvocationMethodSelectAdapts a matcher on MethodInvocationTree to match the MethodSelect of the MethodInvocation. MethodVisibilityA matcher for method visibility (public, private, protected, or default). MultiMatcher.MultiMatchResult<N extends com.sun.source.tree.Tree>A result from the call of
MultiMatcher.multiMatchResult(Tree, VisitorState), containing information about whether it matched, and if so, what nodes matched.
NullnessMatcherMatches an expression based on the result of the nullness dataflow analysis. ReturnsMatches a
returnstatement whose returned expression is matched by the given matcher.
StringLiteral TestNgMatchersMatchers for code patterns which appear to be TestNG-based tests. ThrowsMatches a
throwstatement whose thrown expression is matched by the given matcher.
WaitMatchersMatchers for method invocations related to Object.wait() and Condition.await();