Class MethodInvocationMatcher
java.lang.Object
com.google.errorprone.matchers.method.MethodInvocationMatcher
public class MethodInvocationMatcher extends Object
The machinery and type definitions necessary to model and compile a single efficient matcher out
of a list of
MethodMatchers.MethodMatcher
s.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MethodInvocationMatcher.MethodKind
The kinds of things that count as a method invocation.static class
MethodInvocationMatcher.Rule
A rule describing a set of constraints for a method invocation.static interface
MethodInvocationMatcher.Token
A specific value for a property that a method invocation can have.static class
MethodInvocationMatcher.TokenType
The kinds of properties a matcher can match against. -
Method Summary
Modifier and Type Method Description static Matcher<com.sun.source.tree.ExpressionTree>
compile(Iterable<MethodInvocationMatcher.Rule> rules)
Constructs a Matcher that matches for method invocations (including constructor invocations) satisfying at least one of the given Rule specifications.static <T extends com.sun.source.tree.Tree>
Matcher<T>compiledAnyOf(Iterable<Matcher<? super T>> inputs)
Compose several matchers together, such that the composite matches an AST node if any of the given matchers do.
-
Method Details
-
compiledAnyOf
public static <T extends com.sun.source.tree.Tree> Matcher<T> compiledAnyOf(Iterable<Matcher<? super T>> inputs)Compose several matchers together, such that the composite matches an AST node if any of the given matchers do.This is semantically equivalent to
Matchers.anyOf(Iterable)
, but if the list of matchers contains more than oneMethodMatchers.MethodMatcher
, then anyMethod will do some work up front to try and optimize out the repeated work that those matchers would otherwise do. Consider profiling your matcher before using this method: the up-front work can be substantial, and if the list of matchers is small or the result of this method is not used often, the extra work may not pay for itself. -
compile
public static Matcher<com.sun.source.tree.ExpressionTree> compile(Iterable<MethodInvocationMatcher.Rule> rules)Constructs a Matcher that matches for method invocations (including constructor invocations) satisfying at least one of the given Rule specifications. For an easy way to create such Rules, see the factories inMatchers
returning subtypes ofMethodMatchers.MethodMatcher
.
-