Uses of Interface
com.google.errorprone.matchers.Matcher
Package
Description
Checks added to the java compiler which detect common bug patterns.
Bug patterns related to Dagger.
A predicate DSL for matching javac AST nodes.
Utility code.
-
Uses of Matcher in com.google.errorprone.bugpatterns
Modifier and TypeFieldDescriptionstatic final Matcher
<com.sun.source.tree.BinaryTree> BadShiftAmount.BINARY_TREE_MATCHER
static final Matcher
<com.sun.source.tree.ExpressionTree> CollectorShouldNotUseState.COLLECTOR_OF_CALL
final Matcher
<com.sun.source.tree.Tree> CollectorShouldNotUseState.containsAnonymousClassUsingState
protected static final Matcher
<com.sun.source.tree.Tree> AbstractMustBeClosedChecker.HAS_MUST_BE_CLOSED_ANNOTATION
Matches trees annotated withMustBeClosed
.static final Matcher
<com.sun.source.tree.Tree> DeadException.MATCHER
static final Matcher
<com.sun.source.tree.ExpressionTree> ProtoBuilderReturnValueIgnored.MATCHER
static final Matcher
<com.sun.source.tree.ExpressionTree> StreamResourceLeak.MATCHER
static final Matcher
<com.sun.source.tree.Tree> PreferredInterfaceType.SHOULD_IGNORE
Modifier and TypeMethodDescriptionprotected Matcher
<? super com.sun.source.tree.MethodInvocationTree> AbstractPatternSyntaxChecker.getMatcherWithFlags()
protected Matcher
<? super com.sun.source.tree.MethodInvocationTree> AbstractPatternSyntaxChecker.getMatcherWithoutFlags()
protected Matcher
<com.sun.source.tree.MethodTree> JUnit4SetUpNotRun.methodMatcher()
protected Matcher
<com.sun.source.tree.MethodTree> JUnit4TearDownNotRun.methodMatcher()
protected abstract Matcher
<? super com.sun.source.tree.ExpressionTree> AbstractReturnValueIgnored.specializedMatcher()
Match whatever additional conditions concrete subclasses want to match (a list of known side-effect-free methods, has a @CheckReturnValue annotation, etc.).Matcher
<com.sun.source.tree.ExpressionTree> CheckReturnValue.specializedMatcher()
Return a matcher for method invocations in which the method being called should be considered must-be-used.Matcher
<com.sun.source.tree.ExpressionTree> FutureReturnValueIgnored.specializedMatcher()
protected Matcher
<? super com.sun.source.tree.ExpressionTree> IgnoredPureGetter.specializedMatcher()
Matcher
<? super com.sun.source.tree.ExpressionTree> ProtoBuilderReturnValueIgnored.specializedMatcher()
Matcher
<? super com.sun.source.tree.ExpressionTree> ReturnValueIgnored.specializedMatcher()
Matcher
<? super com.sun.source.tree.ExpressionTree> RxReturnValueIgnored.specializedMatcher()
Modifier and TypeMethodDescriptionstatic AbstractMockChecker.TypeExtractor
<com.sun.source.tree.MethodInvocationTree> AbstractMockChecker.extractClassArg
(Matcher<com.sun.source.tree.MethodInvocationTree> m) Produces an extractor which, if the tree matches, extracts the type of the first argument whose type isClass
(preserving its<T>
type parameter, if it has one}.static AbstractMockChecker.TypeExtractor
<com.sun.source.tree.MethodInvocationTree> AbstractMockChecker.extractFirstArg
(Matcher<com.sun.source.tree.MethodInvocationTree> m) Produces an extractor which, if the tree matches, extracts the type of the first argument to the method invocation.static <T extends com.sun.source.tree.Tree>
AbstractMockChecker.TypeExtractor<T> AbstractMockChecker.extractType
(Matcher<T> m) Produces an extractor which, if the tree matches, extracts the type of that tree, as given byASTHelpers.getType(Tree)
.protected <T extends com.sun.source.tree.Tree>
DescriptionAbstractBanUnsafeAPIChecker.matchHelper
(T tree, VisitorState state, Matcher<T> matcher) protected Description
AbstractMustBeClosedChecker.scanEntireMethodFor
(Matcher<? super com.sun.source.tree.ExpressionTree> matcher, com.sun.source.tree.MethodTree tree, VisitorState state) Scans a method body for invocations matchingmatcher
, emitting them as a single fix.abstract StronglyType.Builder
StronglyType.Builder.setFactoryMatcher
(Matcher<com.sun.source.tree.ExpressionTree> matcher) Set the matcher used to check if an expression is a factory creating a stronger type. -
Uses of Matcher in com.google.errorprone.bugpatterns.android
Modifier and TypeMethodDescriptionMatcher
<? super com.sun.source.tree.ExpressionTree> RectIntersectReturnValueIgnored.specializedMatcher()
-
Uses of Matcher in com.google.errorprone.bugpatterns.inject.dagger
Modifier and TypeMethodDescriptionstatic Matcher
<com.sun.source.tree.Tree> DaggerAnnotations.isAnyModule()
-
Uses of Matcher in com.google.errorprone.matchers
Modifier and TypeInterfaceDescriptioninterface
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.Modifier and TypeClassDescriptionclass
AbstractTypeMatcher<T extends com.sun.source.tree.Tree>
Base class for type matchers.class
Matches an annotation that does not have a particular argument, possibly because the default value is being used.class
class
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.class
class
Matches assert statements which have a condition expression matched by the given matcher.class
ChildMultiMatcher<T extends com.sun.source.tree.Tree,
N extends com.sun.source.tree.Tree> AMultiMatcher
that applies a matcher across multiple children of a single ancestor node.class
A matcher for compile-time-constant expressions.class
Matcher for a compound-assignment operator expression.class
Applies the given matcher to the constructor(s) of the given class.class
A matcher that recursively inspects a tree, applying the given matcher to all levels of each tree and returningtrue
if any match is found.static class
Enclosing.Block<T extends com.sun.source.tree.Tree>
static class
Enclosing.BlockOrCase<T extends com.sun.source.tree.Tree>
static class
Enclosing.Class<T extends com.sun.source.tree.Tree>
static class
Enclosing.Method<T extends com.sun.source.tree.Tree>
class
Matches if the given matcher matches all of/any of the parameters to this method.class
Matches if the given matcher matches all of the identifiers under this syntax tree.final class
Matches expressions that can be statically determined to be non-null.class
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.class
IsSubtypeOf<T extends com.sun.source.tree.Tree>
class
Matches if the given matcher matches all of/any of the parameters to this method.class
Matches a method invocation based on a matcher for the method select (receiver + method identifier) and one for the arguments.class
Applies an Expression matcher to an argument of a MethodInvocation by position.class
A matcher for method visibility (public, private, protected, or default).class
Matches an expression based on the result of the nullness dataflow analysis.class
Matches areturn
statement whose returned expression is matched by the given matcher.class
class
Matches athrow
statement whose thrown expression is matched by the given matcher.final class
Matches expressions that invoke or reference a non-void method or constructor and which do not use their return value and are not in a context where non-use of the return value is allowed.Modifier and TypeFieldDescriptionstatic final Matcher
<com.sun.source.tree.Tree> InjectMatchers.HAS_INJECT_ANNOTATION
static final Matcher
<com.sun.source.tree.MethodTree> JUnitMatchers.hasJUnit4AfterAnnotations
static final Matcher
<com.sun.source.tree.MethodTree> JUnitMatchers.hasJUnit4BeforeAnnotations
static final Matcher
<com.sun.source.tree.ClassTree> JUnitMatchers.hasJUnit4TestCases
Match a class which has one or more methods with a JUnit 4 @Test annotation.static final Matcher
<com.sun.source.tree.Tree> InjectMatchers.INSIDE_GUICE_MODULE
static final Matcher
<com.sun.source.tree.AnnotationTree> InjectMatchers.IS_APPLICATION_OF_AT_INJECT
static final Matcher
<com.sun.source.tree.AnnotationTree> InjectMatchers.IS_APPLICATION_OF_GUICE_INJECT
static final Matcher
<com.sun.source.tree.AnnotationTree> InjectMatchers.IS_APPLICATION_OF_JAVAX_INJECT
static final Matcher
<com.sun.source.tree.AnnotationTree> InjectMatchers.IS_BINDING_ANNOTATION
static final Matcher
<com.sun.source.tree.ClassTree> InjectMatchers.IS_DAGGER_COMPONENT
static final Matcher
<com.sun.source.tree.ClassTree> InjectMatchers.IS_DAGGER_COMPONENT_OR_MODULE
static final Matcher
<com.sun.source.tree.Tree> Matchers.IS_INTERFACE
static final Matcher
<com.sun.source.tree.AnnotationTree> InjectMatchers.IS_SCOPING_ANNOTATION
static final Matcher
<com.sun.source.tree.ClassTree> JUnitMatchers.isAmbiguousJUnitVersion
Matches classes which have attributes of both JUnit 3 and 4 classes.static final Matcher
<com.sun.source.tree.ClassTree> JUnitMatchers.isConcreteClassWithoutRunWith
Match a class which appears to be missing a @RunWith annotation.static final Matcher
<com.sun.source.tree.MethodTree> JUnitMatchers.isJunit3TestCase
Match a method which appears to be a JUnit 3 test case.static final Matcher
<com.sun.source.tree.ClassTree> JUnitMatchers.isJUnit3TestClass
Match a class which appears to be a JUnit 3 test class.static final Matcher
<com.sun.source.tree.ClassTree> JUnitMatchers.isJUnit4TestClass
Matches classes which have attributes of only JUnit4 test classes.static final Matcher
<com.sun.source.tree.ClassTree> JUnitMatchers.isTestCaseDescendant
Matches a class that inherits from TestCase.static final Matcher
<com.sun.source.tree.MethodTree> JUnitMatchers.looksLikeJUnit3SetUp
Match a method which appears to be a JUnit 3 setUp methodstatic final Matcher
<com.sun.source.tree.MethodTree> JUnitMatchers.looksLikeJUnit3TearDown
Match a method which appears to be a JUnit 3 tearDown methodstatic final Matcher
<com.sun.source.tree.MethodTree> JUnitMatchers.looksLikeJUnit4After
Matches a method which appears to be a JUnit4 @After method.static final Matcher
<com.sun.source.tree.MethodTree> JUnitMatchers.looksLikeJUnit4Before
Matches a method which appears to be a JUnit4 @Before method.static final Matcher
<com.sun.source.tree.MethodTree> Matchers.MAIN_METHOD
protected final Matcher
<T> Enclosing.EnclosingMatcher.matcher
protected final Matcher
<T> Enclosing.EnclosingMatcher.matcher
protected final Matcher
<T> Enclosing.EnclosingMatcher.matcher
ChildMultiMatcher.nodeMatcher
The matcher to apply to the subnodes in question.static final Matcher
<com.sun.source.tree.MethodTree> Matchers.SERIALIZATION_METHODS
Method signature of serialization methods.static final Matcher
<com.sun.source.tree.MethodTree> JUnitMatchers.TEST_CASE
Matches a JUnit 3 or 4 test case.static final Matcher
<com.sun.source.tree.MethodInvocationTree> WaitMatchers.waitMethod
Matches any wait/await method.static final Matcher
<com.sun.source.tree.MethodInvocationTree> WaitMatchers.waitMethodWithTimeout
Matches wait/await methods that have a timeout.static final Matcher
<com.sun.source.tree.MethodTree> JUnitMatchers.wouldRunInJUnit4
Matches a method annotated with @Test but not @Ignore.Modifier and TypeMethodDescriptionstatic <T extends com.sun.source.tree.Tree>
Matcher<T> Compose several matchers together, such that the composite matches an AST node iff all the given matchers do.static <T extends com.sun.source.tree.Tree>
Matcher<T> Compose several matchers together, such that the composite matches an AST node iff all the given matchers do.static Matcher
<com.sun.source.tree.ExpressionTree> FieldMatchers.anyFieldInClass
(String className) static <T extends com.sun.source.tree.Tree>
Matcher<T> static <T extends com.sun.source.tree.Tree>
Matcher<T> Compose several matchers together, such that the composite matches an AST node if any of the given matchers do.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.anything()
A matcher that matches any AST node.static Matcher
<com.sun.source.tree.MethodInvocationTree> static Matcher
<com.sun.source.tree.MethodInvocationTree> Matchers.argumentCount
(int argumentCount) static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.assertEqualsInvocation()
Matches calls to the methodorg.junit.Assert#assertEquals
and corresponding methods in JUnit 3.x.static Matcher
<com.sun.source.tree.AssertTree> Matchers.assertionWithCondition
(Matcher<com.sun.source.tree.ExpressionTree> conditionMatcher) Matches an assertion AST node if the given matcher matches its condition.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.assertNotEqualsInvocation()
Matches calls to the methodorg.junit.Assert#assertNotEquals
and corresponding methods in JUnit 3.x.static Matcher
<com.sun.source.tree.StatementTree> Matchers.assertStatement
(Matcher<com.sun.source.tree.ExpressionTree> conditionMatcher) Matches anassert
statement where the condition is matched by the passedconditionMatcher
.static Matcher
<com.sun.source.tree.AssignmentTree> Matchers.assignment
(Matcher<com.sun.source.tree.ExpressionTree> variableMatcher, Matcher<? super com.sun.source.tree.ExpressionTree> expressionMatcher) Matches an assignment operator AST node if both of the given matchers match.static Matcher
<com.sun.source.tree.BinaryTree> Matchers.binaryTree
(Matcher<com.sun.source.tree.ExpressionTree> matcher1, Matcher<com.sun.source.tree.ExpressionTree> matcher2) Matches a binary tree if the given matchers match the operands in either order.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.booleanConstant
(boolean value) Matches the boolean constant (Boolean.TRUE
orBoolean.FALSE
) corresponding to the given value.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.booleanLiteral
(boolean value) static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.classLiteral
(Matcher<? super com.sun.source.tree.ExpressionTree> classMatcher) static Matcher
<com.sun.source.tree.MethodTree> Matchers.compareToMethodDeclaration()
MatchescompareTo
method declaration.static Matcher
<com.sun.source.tree.MethodTree> Matchers.constructorOfClass
(String className) Matches a constructor declaration in a specific enclosing class.static Matcher
<com.sun.source.tree.Tree> Applies the given matcher recursively to all descendants of an AST node, and matches if any matching descendant node is found.static <T extends com.sun.source.tree.Tree,
V extends com.sun.source.tree.Tree>
Matcher<T> Applies the given matcher recursively to all descendants of an AST node, and matches if any matching descendant node is found.static Matcher
<com.sun.source.tree.StatementTree> Matchers.continueStatement()
Matches acontinue
statement.static Matcher
<com.sun.source.tree.AnnotationTree> Matchers.doesNotHaveArgument
(String argumentName) Matches an Annotation AST node if an argument to the annotation does not exist.static Matcher
<com.sun.source.tree.Tree> Matchers.enclosingNode
(Matcher<com.sun.source.tree.Tree> matcher) Matches an AST node that is enclosed by some node that matches the given matcher.static Matcher
<com.sun.source.tree.EnhancedForLoopTree> Matchers.enhancedForLoop
(Matcher<com.sun.source.tree.VariableTree> variableMatcher, Matcher<com.sun.source.tree.ExpressionTree> expressionMatcher, Matcher<com.sun.source.tree.StatementTree> statementMatcher) Matches an enhanced for loop if all the given matchers match.static Matcher
<com.sun.source.tree.MethodTree> Matchers.equalsMethodDeclaration()
MatchesObject.equals(java.lang.Object)
method declaration.static Matcher
<com.sun.source.tree.StatementTree> Matchers.expressionStatement
(Matcher<com.sun.source.tree.ExpressionTree> matcher) Matches anExpressionStatementTree
based on itsExpressionTree
.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.hasAnnotation
(Class<? extends Annotation> inputClass) Determines whether an expression has an annotation of the given class.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.hasAnnotation
(String annotationClass) Determines whether an expression has an annotation of the given type.static Matcher
<com.sun.source.tree.Tree> Matchers.hasAnnotation
(TypeMirror annotationMirror) Determines if an expression has an annotation referred to by the given mirror.static Matcher
<com.sun.source.tree.MethodTree> Matchers.hasAnnotationOnAnyOverriddenMethod
(String annotationClass) Matches if a method or any method it overrides has an annotation of the given type.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.hasAnnotationWithSimpleName
(String simpleName) Determines whether an expression has an annotation with the given simple name.static Matcher
<com.sun.source.tree.Tree> Matchers.hasAnyAnnotation
(Class<? extends Annotation>... annotations) static Matcher
<com.sun.source.tree.Tree> Matchers.hasAnyAnnotation
(List<? extends TypeMirror> mirrors) static Matcher
<com.sun.source.tree.AnnotationTree> Matchers.hasArgumentWithValue
(String argumentName, Matcher<com.sun.source.tree.ExpressionTree> valueMatcher) Matches an Annotation AST node if the argument to the annotation with the given name has a value which matches the given matcher.static Matcher
<com.sun.source.tree.MethodTree> Matchers.hashCodeMethodDeclaration()
MatcheshashCode
method declaration.static Matcher
<com.sun.source.tree.Tree> Matchers.hasIdentifier
(Matcher<com.sun.source.tree.IdentifierTree> nodeMatcher) Matches any AST that contains an identifier with a certain property.static <T extends com.sun.source.tree.Tree>
Matcher<T> InjectMatchers.hasInjectAnnotation()
static Matcher
<com.sun.source.tree.ClassTree> Matches a class in which at least one method matches the given methodMatcher.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.hasModifier
(Modifier modifier) Returns true if the Tree node has the expectedModifier
.static <T extends com.sun.source.tree.Tree>
Matcher<T> InjectMatchers.hasProvidesAnnotation()
static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.ignoreParens
(Matcher<com.sun.source.tree.ExpressionTree> innerMatcher) Ignores any number of parenthesis wrapping an expression and then applies the passed matcher to that expression.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.inLoop()
Matches if the given tree is inside a loop.static Matcher
<com.sun.source.tree.ExpressionTree> CompileTimeConstantExpressionMatcher.instance()
static <T extends com.sun.source.tree.ExpressionTree>
Matcher<T> Matchers.instanceEqualsInvocation()
Matches calls to the methodObject.equals(Object)
or any override of that method.static Matcher
<com.sun.source.tree.ExpressionTree> FieldMatchers.instanceField
(String className, String fieldName) static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.instanceHashCodeInvocation()
Matches calls to the methodObject.hashCode()
or any override of that method.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.inSynchronized()
Matches if this Tree is enclosed by either a synchronized block or a synchronized method.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.intLiteral
(int value) static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.isArrayType()
Matches an AST node if its type is an array type.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.isBoxedPrimitiveType()
Matches an AST node if its type is a boxed primitive type.static Matcher
<com.sun.source.tree.ClassTree> Matchers.isDirectImplementationOf
(String clazz) Matches any node that is directly an implementation, but not extension, of the given Class.static Matcher
<com.sun.source.tree.ClassTree> Matchers.isEnum()
Matches if aClassTree
is an enum declaration.static Matcher
<com.sun.source.tree.ClassTree> Matchers.isExtensionOf
(String clazz) Matches any node that is a direct extension of the given class.static Matcher
<com.sun.source.tree.VariableTree> Matchers.isField()
Matches if aVariableTree
is a field declaration, as opposed to a local variable, enum constant, parameter to a method, etc.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.isInstance
(Class<?> klass) Matches if an AST node is an instance of the given class.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.isInstanceField()
Matches an AST node that represents a non-static field.static Matcher
<com.sun.source.tree.ExpressionTree> JUnitMatchers.isJUnit4TestRunnerOfType
(Iterable<String> runnerTypes) Matches an argument of typeClass<T>
, where T is a subtype of one of the test runners listed in the TEST_RUNNERS field.static Matcher
<com.sun.source.tree.StatementTree> Matchers.isLastStatementInBlock()
Matches a statement AST node if the statement is the last statement in the block.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.isNonNull()
Deprecated.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.isNonNullUsingDataflow()
Matches if the expression is provably non-null.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.isNull()
Deprecated.useMatchers.isNullUsingDataflow()
instead.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.isNullUsingDataflow()
Matches if the expression is provably null.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.isPrimitiveArrayType()
Matches an AST node if its type is a primitive array type.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.isPrimitiveOrBoxedPrimitiveType()
Matches an AST node if its type is a primitive type, or a boxed version of a primitive type.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.isPrimitiveOrVoidType()
Matches an AST node if its type is either a primitive type or avoid
type.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.isPrimitiveType()
Matches an AST node if its type is a primitive type.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.isSame
(com.sun.source.tree.Tree t) Matches an AST node which is the same object reference as the given node.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.isSameType
(Supplier<com.sun.tools.javac.code.Type> type) Matches an AST node if it has the same erased type as the given type.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.isSameType
(Class<?> clazz) Matches an AST node if it has the same erased type as the given class.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.isSameType
(String typeString) Matches an AST node if it has the same erased type as the given type.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.isStatic()
Matches an AST node that is static.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.isSubtypeOf
(Supplier<com.sun.tools.javac.code.Type> type) Matches an AST node if its type is a subtype of the given type.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.isSubtypeOf
(Class<?> clazz) Matches an AST node if its type is a subtype of the given type.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.isSubtypeOf
(String typeStr) Matches an AST node if its type is a subtype of the given type.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.isTransient()
Matches an AST node that is transient.static Matcher
<com.sun.source.tree.AnnotationTree> static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.isVariable()
Matches an AST node that represents a local variable or parameter.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.isVoidType()
Matches an AST node if its type is avoid
type.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matches an AST node of a given kind, for example, an Annotation or a switch block.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.kindIs
(com.sun.source.tree.Tree.Kind kind) Matches an AST node of a given kind, for example, an Annotation or a switch block.static Matcher
<com.sun.source.tree.StatementTree> Matchers.matchExpressionReturn
(Matcher<com.sun.source.tree.ExpressionTree> expressionTreeMatcher) Matches theTree
if it returns an expression matchingexpressionTreeMatcher
.static Matcher
<com.sun.source.tree.BlockTree> Matchers.matchSingleStatementBlock
(Matcher<com.sun.source.tree.StatementTree> statementMatcher) Matches aBlockTree
if it single statement block with statement matchingstatementMatcher
.static Matcher
<com.sun.source.tree.MethodTree> Matchers.methodHasArity
(int arity) Matches if the method accepts the given number of arguments.static Matcher
<com.sun.source.tree.MethodTree> Matchers.methodHasNoParameters()
Matches an AST node that represents a method declaration with no parameters.static Matcher
<com.sun.source.tree.MethodTree> Matchers.methodHasParameters
(Matcher<com.sun.source.tree.VariableTree>... variableMatcher) Matches an AST node that represents a method declaration, based on the list of variableMatchers.static Matcher
<com.sun.source.tree.MethodTree> Matchers.methodHasParameters
(List<Matcher<com.sun.source.tree.VariableTree>> variableMatcher) Matches an AST node that represents a method declaration, based on the list of variableMatchers.static Matcher
<com.sun.source.tree.MethodTree> Matchers.methodHasVisibility
(MethodVisibility.Visibility visibility) static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.methodInvocation
(Matcher<com.sun.source.tree.ExpressionTree> methodSelectMatcher) Matches an AST node if it is a method invocation and the method select matchesmethodSelectMatcher
.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.methodInvocation
(Matcher<com.sun.source.tree.ExpressionTree> methodSelectMatcher, ChildMultiMatcher.MatchType matchType, Matcher<com.sun.source.tree.ExpressionTree> methodArgumentMatcher) Matches an AST node if it is a method invocation and the given matchers match.static Matcher
<com.sun.source.tree.MethodTree> Matchers.methodIsConstructor()
static Matcher
<com.sun.source.tree.MethodTree> Matchers.methodIsNamed
(String methodName) Match a method declaration with a specific name.static Matcher
<com.sun.source.tree.MethodTree> Matchers.methodNameStartsWith
(String prefix) Match a method declaration that starts with a given string.static Matcher
<com.sun.source.tree.MethodTree> Matchers.methodReturns
(Matcher<? super com.sun.source.tree.Tree> returnTypeMatcher) static Matcher
<com.sun.source.tree.MethodTree> Matchers.methodReturns
(Supplier<com.sun.tools.javac.code.Type> returnType) static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.methodReturnsNonNull()
Matches a method invocation that is known to never return null.static Matcher
<com.sun.source.tree.MethodTree> Matchers.methodReturnsNonPrimitiveType()
Match a method that returns a non-primitive type.static Matcher
<com.sun.source.tree.MethodTree> Matchers.methodWithClassAndName
(String className, String methodName) Match a method declaration with a specific enclosing class and method name.static Matcher
<com.sun.source.tree.ClassTree> Matchers.nestingKind
(NestingKind kind) Matches an class based on whether it is nested in another class or method.static <T extends com.sun.source.tree.StatementTree>
Matcher<T> Matchers.nextStatement
(Matcher<com.sun.source.tree.StatementTree> matcher) Matches a statement AST node if the following statement in the enclosing block matches the given matcher.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.nonNullLiteral()
Matches an AST node if it is a literal other than null.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matches an AST node iff it does not match the given matcher.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.nothing()
A matcher that matches no AST node.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.nullLiteral()
Matches an AST node if it is a null literal.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.packageMatches
(Predicate<String> predicate) Matches an AST node whose compilation unit's package name matches the given predicate.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.packageMatches
(Pattern pattern) Matches an AST node whose compilation unit's package name matches the given pattern.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.packageStartsWith
(String prefix) Matches an AST node whose compilation unit starts with this prefix.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.parentNode
(Matcher<com.sun.source.tree.Tree> treeMatcher) Matches an AST node if its parent node is matched by the given matcher.static <T extends com.sun.source.tree.StatementTree>
Matcher<T> Matchers.previousStatement
(Matcher<com.sun.source.tree.StatementTree> matcher) Matches a statement AST node if the previous statement in the enclosing block matches the given matcher.static Matcher
<com.sun.source.tree.MethodInvocationTree> Matchers.receiverOfInvocation
(Matcher<com.sun.source.tree.ExpressionTree> expressionTreeMatcher) static Matcher
<? super com.sun.source.tree.MethodInvocationTree> Matchers.receiverSameAsArgument
(int argNum) Matches when the receiver of an instance method is the same reference as a particular argument to the method.static Matcher
<com.sun.source.tree.StatementTree> Matchers.returnStatement
(Matcher<? super com.sun.source.tree.ExpressionTree> returnedMatcher) Matches areturn
statement where the returned expression is matched by the passedreturnedMatcher
.static Matcher
<? super com.sun.source.tree.MethodInvocationTree> Matchers.sameArgument
(int index1, int index2) Matches aMethodInvocation
when the arguments at the two given indices are both the same variable, as determined byASTHelpers.sameVariable(com.sun.source.tree.ExpressionTree, com.sun.source.tree.ExpressionTree)
.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.sameVariable
(com.sun.source.tree.ExpressionTree expr) Matches if this ExpressionTree refers to the same variable as the one passed into the matcher.static Matcher
<com.sun.source.tree.MethodTree> Matchers.singleStatementReturnMatcher
(Matcher<com.sun.source.tree.ExpressionTree> expressionTreeMatcher) Returns a matcher forMethodTree
whose implementation contains a single return statement with expression matching the passedexpressionTreeMatcher
.static <T extends com.sun.source.tree.ExpressionTree>
Matcher<T> Matchers.staticEqualsInvocation()
Matches an invocation of a recognized static object equality method such asObjects.equals(java.lang.Object, java.lang.Object)
.static Matcher
<com.sun.source.tree.ExpressionTree> FieldMatchers.staticField
(String className, String fieldName) static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.staticFieldAccess()
Matches an AST node which is an expression yielding the indicated static field access.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.stringLiteral
(String value) Matches a Literal AST node if it is a string literal with the given value.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.stringLiteral
(Pattern pattern) Matches a Literal AST node if it is a string literal which matches the givenPattern
.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.symbolHasAnnotation
(Class<? extends Annotation> inputClass) Determines whether an expression refers to a symbol that has an annotation of the given type.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.symbolHasAnnotation
(String annotationClass) Determines whether an expression refers to a symbol that has an annotation of the given type.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.symbolMatcher
(BiPredicate<com.sun.tools.javac.code.Symbol, VisitorState> pred) Match a Tree based solely on the Symbol produced byASTHelpers.getSymbol(Tree)
.static Matcher
<com.sun.source.tree.StatementTree> Matchers.throwStatement
(Matcher<? super com.sun.source.tree.ExpressionTree> thrownMatcher) Matches athrow
statement where the thrown item is matched by the passedthrownMatcher
.static Matcher
<com.sun.source.tree.MethodTree> Matchers.toStringMethodDeclaration()
MatchesObject.toString()
method declaration.static <S extends T,
T extends com.sun.source.tree.Tree>
Matcher<T> Converts the given matcher to one that can be applied to any tree but is only executed when run on a tree oftype
and returnsfalse
for all other tree types.static Matcher
<com.sun.source.tree.TypeCastTree> Matchers.typeCast
(Matcher<com.sun.source.tree.Tree> typeMatcher, Matcher<com.sun.source.tree.ExpressionTree> expressionMatcher) Matches a type cast AST node if both of the given matchers match.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.typePredicateMatcher
(TypePredicate pred) Match a Tree based solely on the type produced byASTHelpers.getType(Tree)
.static Matcher
<com.sun.source.tree.VariableTree> Matchers.variableInitializer
(Matcher<com.sun.source.tree.ExpressionTree> expressionTreeMatcher) Matches on the initializer of a VariableTree AST node.static Matcher
<com.sun.source.tree.VariableTree> Matchers.variableType
(Matcher<com.sun.source.tree.Tree> treeMatcher) Matches on the type of a VariableTree AST node.Modifier and TypeMethodDescriptionstatic <T extends com.sun.source.tree.Tree>
Matcher<T> Compose several matchers together, such that the composite matches an AST node iff all the given matchers do.static <T extends com.sun.source.tree.Tree>
MultiMatcher<T, com.sun.source.tree.AnnotationTree> Matchers.annotations
(ChildMultiMatcher.MatchType matchType, Matcher<com.sun.source.tree.AnnotationTree> annotationMatcher) Matches if the given annotation matcher matches all of or any of the annotations on this tree node.static <T extends com.sun.source.tree.Tree>
Matcher<T> static Matcher
<com.sun.source.tree.MethodInvocationTree> static Matcher
<com.sun.source.tree.AssertTree> Matchers.assertionWithCondition
(Matcher<com.sun.source.tree.ExpressionTree> conditionMatcher) Matches an assertion AST node if the given matcher matches its condition.static Matcher
<com.sun.source.tree.StatementTree> Matchers.assertStatement
(Matcher<com.sun.source.tree.ExpressionTree> conditionMatcher) Matches anassert
statement where the condition is matched by the passedconditionMatcher
.static Matcher
<com.sun.source.tree.AssignmentTree> Matchers.assignment
(Matcher<com.sun.source.tree.ExpressionTree> variableMatcher, Matcher<? super com.sun.source.tree.ExpressionTree> expressionMatcher) Matches an assignment operator AST node if both of the given matchers match.static Matcher
<com.sun.source.tree.BinaryTree> Matchers.binaryTree
(Matcher<com.sun.source.tree.ExpressionTree> matcher1, Matcher<com.sun.source.tree.ExpressionTree> matcher2) Matches a binary tree if the given matchers match the operands in either order.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.classLiteral
(Matcher<? super com.sun.source.tree.ExpressionTree> classMatcher) static CompoundAssignment
Matchers.compoundAssignment
(com.sun.source.tree.Tree.Kind operator, Matcher<com.sun.source.tree.ExpressionTree> leftOperandMatcher, Matcher<com.sun.source.tree.ExpressionTree> rightOperandMatcher) Matches a compound assignment operator AST node which matches a given left-operand matcher, a given right-operand matcher, and a specific compound assignment operator.static CompoundAssignment
Matchers.compoundAssignment
(Set<com.sun.source.tree.Tree.Kind> operators, Matcher<com.sun.source.tree.ExpressionTree> receiverMatcher, Matcher<com.sun.source.tree.ExpressionTree> expressionMatcher) Matches a compound assignment operator AST node which matches a given left-operand matcher, a given right-operand matcher, and is one of a set of compound assignment operators.static MultiMatcher
<com.sun.source.tree.ClassTree, com.sun.source.tree.MethodTree> Matchers.constructor
(ChildMultiMatcher.MatchType matchType, Matcher<com.sun.source.tree.MethodTree> constructorMatcher) Matches a class in which any of/all of its constructors match the given constructorMatcher.static Matcher
<com.sun.source.tree.Tree> Applies the given matcher recursively to all descendants of an AST node, and matches if any matching descendant node is found.static <T extends com.sun.source.tree.Tree,
V extends com.sun.source.tree.Tree>
Matcher<T> Applies the given matcher recursively to all descendants of an AST node, and matches if any matching descendant node is found.static <T extends com.sun.source.tree.Tree>
Enclosing.Block<T> Matchers.enclosingBlock
(Matcher<com.sun.source.tree.BlockTree> matcher) Matches an AST node which is enclosed by a block node that matches the given matcher.static <T extends com.sun.source.tree.Tree>
Enclosing.Class<T> Matchers.enclosingClass
(Matcher<com.sun.source.tree.ClassTree> matcher) Matches an AST node which is enclosed by a class node that matches the given matcher.static <T extends com.sun.source.tree.Tree>
Enclosing.Method<T> Matchers.enclosingMethod
(Matcher<com.sun.source.tree.MethodTree> matcher) Matches an AST node which is enclosed by a method node that matches the given matcher.static Matcher
<com.sun.source.tree.Tree> Matchers.enclosingNode
(Matcher<com.sun.source.tree.Tree> matcher) Matches an AST node that is enclosed by some node that matches the given matcher.static Matcher
<com.sun.source.tree.EnhancedForLoopTree> Matchers.enhancedForLoop
(Matcher<com.sun.source.tree.VariableTree> variableMatcher, Matcher<com.sun.source.tree.ExpressionTree> expressionMatcher, Matcher<com.sun.source.tree.StatementTree> statementMatcher) Matches an enhanced for loop if all the given matchers match.static Matcher
<com.sun.source.tree.StatementTree> Matchers.expressionStatement
(Matcher<com.sun.source.tree.ExpressionTree> matcher) Matches anExpressionStatementTree
based on itsExpressionTree
.static MultiMatcher
<com.sun.source.tree.MethodInvocationTree, com.sun.source.tree.ExpressionTree> Matchers.hasArguments
(ChildMultiMatcher.MatchType matchType, Matcher<com.sun.source.tree.ExpressionTree> argumentMatcher) Matches if the given matcher matches all of/any of the arguments to this method invocation.static Matcher
<com.sun.source.tree.AnnotationTree> Matchers.hasArgumentWithValue
(String argumentName, Matcher<com.sun.source.tree.ExpressionTree> valueMatcher) Matches an Annotation AST node if the argument to the annotation with the given name has a value which matches the given matcher.static Matcher
<com.sun.source.tree.Tree> Matchers.hasIdentifier
(Matcher<com.sun.source.tree.IdentifierTree> nodeMatcher) Matches any AST that contains an identifier with a certain property.static Matcher
<com.sun.source.tree.ClassTree> Matches a class in which at least one method matches the given methodMatcher.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.ignoreParens
(Matcher<com.sun.source.tree.ExpressionTree> innerMatcher) Ignores any number of parenthesis wrapping an expression and then applies the passed matcher to that expression.static Matcher
<com.sun.source.tree.StatementTree> Matchers.matchExpressionReturn
(Matcher<com.sun.source.tree.ExpressionTree> expressionTreeMatcher) Matches theTree
if it returns an expression matchingexpressionTreeMatcher
.static Matcher
<com.sun.source.tree.BlockTree> Matchers.matchSingleStatementBlock
(Matcher<com.sun.source.tree.StatementTree> statementMatcher) Matches aBlockTree
if it single statement block with statement matchingstatementMatcher
.static MultiMatcher
<com.sun.source.tree.MethodTree, com.sun.source.tree.VariableTree> Matchers.methodHasParameters
(ChildMultiMatcher.MatchType matchType, Matcher<com.sun.source.tree.VariableTree> parameterMatcher) Matches if the given matcher matches all of/any of the parameters to this method.static Matcher
<com.sun.source.tree.MethodTree> Matchers.methodHasParameters
(Matcher<com.sun.source.tree.VariableTree>... variableMatcher) Matches an AST node that represents a method declaration, based on the list of variableMatchers.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.methodInvocation
(Matcher<com.sun.source.tree.ExpressionTree> methodSelectMatcher) Matches an AST node if it is a method invocation and the method select matchesmethodSelectMatcher
.static Matcher
<com.sun.source.tree.ExpressionTree> Matchers.methodInvocation
(Matcher<com.sun.source.tree.ExpressionTree> methodSelectMatcher, ChildMultiMatcher.MatchType matchType, Matcher<com.sun.source.tree.ExpressionTree> methodArgumentMatcher) Matches an AST node if it is a method invocation and the given matchers match.static Matcher
<com.sun.source.tree.MethodTree> Matchers.methodReturns
(Matcher<? super com.sun.source.tree.Tree> returnTypeMatcher) static <T extends com.sun.source.tree.StatementTree>
Matcher<T> Matchers.nextStatement
(Matcher<com.sun.source.tree.StatementTree> matcher) Matches a statement AST node if the following statement in the enclosing block matches the given matcher.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matches an AST node iff it does not match the given matcher.static <T extends com.sun.source.tree.Tree>
Matcher<T> Matchers.parentNode
(Matcher<com.sun.source.tree.Tree> treeMatcher) Matches an AST node if its parent node is matched by the given matcher.static <T extends com.sun.source.tree.StatementTree>
Matcher<T> Matchers.previousStatement
(Matcher<com.sun.source.tree.StatementTree> matcher) Matches a statement AST node if the previous statement in the enclosing block matches the given matcher.static Matcher
<com.sun.source.tree.MethodInvocationTree> Matchers.receiverOfInvocation
(Matcher<com.sun.source.tree.ExpressionTree> expressionTreeMatcher) static Matcher
<com.sun.source.tree.StatementTree> Matchers.returnStatement
(Matcher<? super com.sun.source.tree.ExpressionTree> returnedMatcher) Matches areturn
statement where the returned expression is matched by the passedreturnedMatcher
.static Matcher
<com.sun.source.tree.MethodTree> Matchers.singleStatementReturnMatcher
(Matcher<com.sun.source.tree.ExpressionTree> expressionTreeMatcher) Returns a matcher forMethodTree
whose implementation contains a single return statement with expression matching the passedexpressionTreeMatcher
.static Matcher
<com.sun.source.tree.StatementTree> Matchers.throwStatement
(Matcher<? super com.sun.source.tree.ExpressionTree> thrownMatcher) Matches athrow
statement where the thrown item is matched by the passedthrownMatcher
.static <S extends T,
T extends com.sun.source.tree.Tree>
Matcher<T> Converts the given matcher to one that can be applied to any tree but is only executed when run on a tree oftype
and returnsfalse
for all other tree types.static Matcher
<com.sun.source.tree.TypeCastTree> Matchers.typeCast
(Matcher<com.sun.source.tree.Tree> typeMatcher, Matcher<com.sun.source.tree.ExpressionTree> expressionMatcher) Matches a type cast AST node if both of the given matchers match.static Matcher
<com.sun.source.tree.VariableTree> Matchers.variableInitializer
(Matcher<com.sun.source.tree.ExpressionTree> expressionTreeMatcher) Matches on the initializer of a VariableTree AST node.static Matcher
<com.sun.source.tree.VariableTree> Matchers.variableType
(Matcher<com.sun.source.tree.Tree> treeMatcher) Matches on the type of a VariableTree AST node.Modifier and TypeMethodDescriptionstatic <T extends com.sun.source.tree.Tree>
Matcher<T> Compose several matchers together, such that the composite matches an AST node iff all the given matchers do.static <T extends com.sun.source.tree.Tree>
Matcher<T> Compose several matchers together, such that the composite matches an AST node if any of the given matchers do.static Matcher
<com.sun.source.tree.MethodTree> Matchers.methodHasParameters
(List<Matcher<com.sun.source.tree.VariableTree>> variableMatcher) Matches an AST node that represents a method declaration, based on the list of variableMatchers.ModifierConstructorDescriptionAnnotationHasArgumentWithValue
(String element, Matcher<com.sun.source.tree.ExpressionTree> valueMatcher) AnnotationMatcher
(ChildMultiMatcher.MatchType matchType, Matcher<com.sun.source.tree.AnnotationTree> nodeMatcher) BlockOrCase
(Matcher<com.sun.source.tree.BlockTree> blockTreeMatcher, Matcher<com.sun.source.tree.CaseTree> caseTreeMatcher) ChildMultiMatcher
(ChildMultiMatcher.MatchType matchType, Matcher<N> nodeMatcher) CompoundAssignment
(Set<com.sun.source.tree.Tree.Kind> operators, Matcher<com.sun.source.tree.ExpressionTree> receiverMatcher, Matcher<com.sun.source.tree.ExpressionTree> expressionMatcher) Creates a new compound-assignment operator matcher, which matches a compound assignment expression with one of a set of operators and whose receiver and expression match the given matchers.ConstructorOfClass
(ChildMultiMatcher.MatchType matchType, Matcher<com.sun.source.tree.MethodTree> nodeMatcher) HasArguments
(ChildMultiMatcher.MatchType matchType, Matcher<com.sun.source.tree.ExpressionTree> nodeMatcher) HasIdentifier
(Matcher<com.sun.source.tree.IdentifierTree> nodeMatcher) MethodHasParameters
(ChildMultiMatcher.MatchType matchType, Matcher<com.sun.source.tree.VariableTree> nodeMatcher) MethodInvocation
(Matcher<com.sun.source.tree.ExpressionTree> methodSelectMatcher, ChildMultiMatcher.MatchType matchType, Matcher<com.sun.source.tree.ExpressionTree> methodArgumentMatcher) Creates a new matcher for method invocations based on a method select and an argument matcher.MethodInvocationArgument
(int position, Matcher<com.sun.source.tree.ExpressionTree> argumentMatcher) New matcher for areturn
statement where the returned expression is matched by the passedreturnedMatcher
.New matcher for athrow
statement where the thrown item is matched by the passedthrownMatcher
. -
Uses of Matcher in com.google.errorprone.matchers.method
Modifier and TypeInterfaceDescriptionstatic interface
Deprecated.useMatcher<ExpressionTree>
instead of referring directly to this type.static interface
Deprecated.useMatcher<ExpressionTree>
instead of referring directly to this type.static interface
Deprecated.useMatcher<ExpressionTree>
instead of referring directly to this type.static interface
Deprecated.useMatcher<ExpressionTree>
instead of referring directly to this type.static interface
Deprecated.useMatcher<ExpressionTree>
instead of referring directly to this type.static interface
Deprecated.useMatcher<ExpressionTree>
instead of referring directly to this type.static interface
Deprecated.useMatcher<ExpressionTree>
instead of referring directly to this type.static interface
Deprecated.useMatcher<ExpressionTree>
instead of referring directly to this type.static interface
Deprecated.useMatcher<ExpressionTree>
instead of referring directly to this type.static interface
Deprecated.useMatcher<ExpressionTree>
instead of referring directly to this type.Modifier and TypeMethodDescriptionstatic Matcher
<com.sun.source.tree.ExpressionTree> MethodInvocationMatcher.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. -
Uses of Matcher in com.google.errorprone.util
Modifier and TypeMethodDescriptionstatic @Nullable List
<com.sun.source.tree.ExpressionTree> ASTHelpers.matchBinaryTree
(com.sun.source.tree.BinaryTree tree, List<Matcher<com.sun.source.tree.ExpressionTree>> matchers, VisitorState state) Given a BinaryTree to match against and a list of two matchers, applies the matchers to the operands in both orders.
Matchers.isNonNullUsingDataflow()
instead.