Uses of Interface
com.google.errorprone.matchers.Matcher
Packages that use 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
Fields in com.google.errorprone.bugpatterns declared as MatcherModifier and TypeFieldDescriptionstatic final Matcher<BinaryTree> BadShiftAmount.BINARY_TREE_MATCHERstatic final Matcher<ExpressionTree> CollectorShouldNotUseState.COLLECTOR_OF_CALLCollectorShouldNotUseState.containsAnonymousClassUsingStateAbstractMustBeClosedChecker.HAS_MUST_BE_CLOSED_ANNOTATIONMatches trees annotated withMustBeClosed.DeadException.MATCHERstatic final Matcher<ExpressionTree> ProtoBuilderReturnValueIgnored.MATCHERstatic final Matcher<ExpressionTree> StreamResourceLeak.MATCHERPreferredInterfaceType.SHOULD_IGNOREMethods in com.google.errorprone.bugpatterns that return MatcherModifier and TypeMethodDescriptionprotected Matcher<? super MethodInvocationTree> AbstractPatternSyntaxChecker.getMatcherWithFlags()protected Matcher<? super MethodInvocationTree> AbstractPatternSyntaxChecker.getMatcherWithoutFlags()protected Matcher<MethodTree> JUnit4SetUpNotRun.methodMatcher()protected Matcher<MethodTree> JUnit4TearDownNotRun.methodMatcher()protected abstract Matcher<? super 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.).CheckReturnValue.specializedMatcher()Return a matcher for method invocations in which the method being called should be considered must-be-used.FutureReturnValueIgnored.specializedMatcher()protected Matcher<? super ExpressionTree> IgnoredPureGetter.specializedMatcher()Matcher<? super ExpressionTree> ProtoBuilderReturnValueIgnored.specializedMatcher()Matcher<? super ExpressionTree> ReturnValueIgnored.specializedMatcher()Matcher<? super ExpressionTree> RxReturnValueIgnored.specializedMatcher()Methods in com.google.errorprone.bugpatterns with parameters of type MatcherModifier and TypeMethodDescriptionAbstractMockChecker.extractClassArg(Matcher<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}.AbstractMockChecker.extractFirstArg(Matcher<MethodInvocationTree> m) Produces an extractor which, if the tree matches, extracts the type of the first argument to the method invocation.static <T extends 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 Tree>
DescriptionAbstractBanUnsafeAPIChecker.matchHelper(T tree, VisitorState state, Matcher<T> matcher) protected DescriptionAbstractMustBeClosedChecker.scanEntireMethodFor(Matcher<? super ExpressionTree> matcher, MethodTree tree, VisitorState state) Scans a method body for invocations matchingmatcher, emitting them as a single fix.abstract StronglyType.BuilderStronglyType.Builder.setFactoryMatcher(Matcher<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
Methods in com.google.errorprone.bugpatterns.android that return MatcherModifier and TypeMethodDescriptionMatcher<? super ExpressionTree> RectIntersectReturnValueIgnored.specializedMatcher() -
Uses of Matcher in com.google.errorprone.bugpatterns.inject.dagger
Methods in com.google.errorprone.bugpatterns.inject.dagger that return Matcher -
Uses of Matcher in com.google.errorprone.matchers
Subinterfaces of Matcher in com.google.errorprone.matchersModifier and TypeInterfaceDescriptioninterfaceMultiMatcher<T extends Tree, N extends Tree>An matcher that applies a single matcher across multiple tree nodes.Classes in com.google.errorprone.matchers that implement MatcherModifier and TypeClassDescriptionclassAbstractTypeMatcher<T extends Tree>Base class for type matchers.classMatches an annotation that does not have a particular argument, possibly because the default value is being used.classclassAnnotationMatcher<T extends Tree>Matches if the given annotation matcher matches all of or any of the annotations on the tree node.classclassMatches assert statements which have a condition expression matched by the given matcher.classChildMultiMatcher<T extends Tree, N extends Tree>AMultiMatcherthat applies a matcher across multiple children of a single ancestor node.classA matcher for compile-time-constant expressions.classMatcher for a compound-assignment operator expression.classApplies the given matcher to the constructor(s) of the given class.classA matcher that recursively inspects a tree, applying the given matcher to all levels of each tree and returningtrueif any match is found.static classEnclosing.Block<T extends Tree>static classEnclosing.BlockOrCase<T extends Tree>static classEnclosing.Class<T extends Tree>static classEnclosing.Method<T extends Tree>classMatches if the given matcher matches all of/any of the parameters to this method.classMatches if the given matcher matches all of the identifiers under this syntax tree.final classMatches expressions that can be statically determined to be non-null.classIsSameType<T extends Tree>Matches an AST node if its erased type is the same as the given type, e.g.classIsSubtypeOf<T extends Tree>classMatches if the given matcher matches all of/any of the parameters to this method.classMatches a method invocation based on a matcher for the method select (receiver + method identifier) and one for the arguments.classApplies an Expression matcher to an argument of a MethodInvocation by position.classA matcher for method visibility (public, private, protected, or default).classMatches an expression based on the result of the nullness dataflow analysis.classMatches areturnstatement whose returned expression is matched by the given matcher.classclassMatches athrowstatement whose thrown expression is matched by the given matcher.final classMatches 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.Fields in com.google.errorprone.matchers declared as MatcherModifier and TypeFieldDescriptionInjectMatchers.HAS_INJECT_ANNOTATIONstatic final Matcher<MethodTree> JUnitMatchers.hasJUnit4AfterAnnotationsstatic final Matcher<MethodTree> JUnitMatchers.hasJUnit4BeforeAnnotationsJUnitMatchers.hasJUnit4TestCasesMatch a class which has one or more methods with a JUnit 4 @Test annotation.InjectMatchers.INSIDE_GUICE_MODULEstatic final Matcher<ExpressionTree> Matchers.INSTANCE_EQUALSstatic final Matcher<AnnotationTree> InjectMatchers.IS_APPLICATION_OF_AT_INJECTstatic final Matcher<AnnotationTree> InjectMatchers.IS_APPLICATION_OF_GUICE_INJECTstatic final Matcher<AnnotationTree> InjectMatchers.IS_APPLICATION_OF_JAVAX_INJECTstatic final Matcher<AnnotationTree> InjectMatchers.IS_BINDING_ANNOTATIONInjectMatchers.IS_DAGGER_COMPONENTInjectMatchers.IS_DAGGER_COMPONENT_OR_MODULEMatchers.IS_INTERFACEstatic final Matcher<AnnotationTree> InjectMatchers.IS_SCOPING_ANNOTATIONJUnitMatchers.isAmbiguousJUnitVersionMatches classes which have attributes of both JUnit 3 and 4 classes.JUnitMatchers.isConcreteClassWithoutRunWithMatch a class which appears to be missing a @RunWith annotation.static final Matcher<MethodTree> JUnitMatchers.isJunit3TestCaseMatch a method which appears to be a JUnit 3 test case.JUnitMatchers.isJUnit3TestClassMatch a class which appears to be a JUnit 3 test class.JUnitMatchers.isJUnit4TestClassMatches classes which have attributes of only JUnit4 test classes.JUnitMatchers.isTestCaseDescendantMatches a class that inherits from TestCase.static final Matcher<MethodTree> JUnitMatchers.looksLikeJUnit3SetUpMatch a method which appears to be a JUnit 3 setUp methodstatic final Matcher<MethodTree> JUnitMatchers.looksLikeJUnit3TearDownMatch a method which appears to be a JUnit 3 tearDown methodstatic final Matcher<MethodTree> JUnitMatchers.looksLikeJUnit4AfterMatches a method which appears to be a JUnit4 @After method.static final Matcher<MethodTree> JUnitMatchers.looksLikeJUnit4BeforeMatches a method which appears to be a JUnit4 @Before method.static final Matcher<MethodTree> Matchers.MAIN_METHODChildMultiMatcher.nodeMatcherThe matcher to apply to the subnodes in question.static final Matcher<MethodTree> Matchers.SERIALIZATION_METHODSMethod signature of serialization methods.static final Matcher<MethodTree> JUnitMatchers.TEST_CASEMatches a JUnit 3 or 4 test case.static final Matcher<MethodInvocationTree> WaitMatchers.WAIT_METHODMatches any wait/await method.static final Matcher<MethodInvocationTree> WaitMatchers.WAIT_METHOD_WITH_TIMEOUTMatches wait/await methods that have a timeout.static final Matcher<MethodTree> JUnitMatchers.wouldRunInJUnit4Matches a method annotated with @Test but not @Ignore.Methods in com.google.errorprone.matchers that return MatcherModifier and TypeMethodDescriptionCompose several matchers together, such that the composite matches an AST node iff all the given matchers do.Compose several matchers together, such that the composite matches an AST node iff all the given matchers do.static Matcher<ExpressionTree> FieldMatchers.anyFieldInClass(String className) Compose several matchers together, such that the composite matches an AST node if any of the given matchers do.Matchers.anything()A matcher that matches any AST node.static Matcher<MethodInvocationTree> Matchers.argument(int position, Matcher<ExpressionTree> argumentMatcher) static Matcher<MethodInvocationTree> Matchers.argumentCount(int argumentCount) static Matcher<ExpressionTree> Matchers.assertEqualsInvocation()Matches calls to the methodorg.junit.Assert#assertEqualsand corresponding methods in JUnit 3.x.static Matcher<AssertTree> Matchers.assertionWithCondition(Matcher<ExpressionTree> conditionMatcher) Matches an assertion AST node if the given matcher matches its condition.static Matcher<ExpressionTree> Matchers.assertNotEqualsInvocation()Matches calls to the methodorg.junit.Assert#assertNotEqualsand corresponding methods in JUnit 3.x.static Matcher<StatementTree> Matchers.assertStatement(Matcher<ExpressionTree> conditionMatcher) Matches anassertstatement where the condition is matched by the passedconditionMatcher.static Matcher<AssignmentTree> Matchers.assignment(Matcher<ExpressionTree> variableMatcher, Matcher<? super ExpressionTree> expressionMatcher) Matches an assignment operator AST node if both of the given matchers match.static Matcher<BinaryTree> Matchers.binaryTree(Matcher<ExpressionTree> matcher1, Matcher<ExpressionTree> matcher2) Matches a binary tree if the given matchers match the operands in either order.static Matcher<ExpressionTree> Matchers.booleanConstant(boolean value) Matches the boolean constant (Boolean.TRUEorBoolean.FALSE) corresponding to the given value.static Matcher<ExpressionTree> Matchers.booleanLiteral(boolean value) static Matcher<ExpressionTree> Matchers.classLiteral(Matcher<? super ExpressionTree> classMatcher) Matches a class literal with the given class matcher.static Matcher<MethodTree> Matchers.compareToMethodDeclaration()MatchescompareTomethod declaration.static Matcher<MethodTree> Matchers.constructorOfClass(String className) Matches a constructor declaration in a specific enclosing class.Applies the given matcher recursively to all descendants of an AST node, and matches if any matching descendant node is found.Applies the given matcher recursively to all descendants of an AST node, and matches if any matching descendant node is found.static Matcher<StatementTree> Matchers.continueStatement()Matches acontinuestatement.static Matcher<AnnotationTree> Matchers.doesNotHaveArgument(String argumentName) Matches an Annotation AST node if an argument to the annotation does not exist.Matchers.enclosingNode(Matcher<Tree> matcher) Matches an AST node that is enclosed by some node that matches the given matcher.static Matcher<EnhancedForLoopTree> Matchers.enhancedForLoop(Matcher<VariableTree> variableMatcher, Matcher<ExpressionTree> expressionMatcher, Matcher<StatementTree> statementMatcher) Matches an enhanced for loop if all the given matchers match.static Matcher<MethodTree> Matchers.equalsMethodDeclaration()MatchesObject.equals(Object)method declaration.static Matcher<StatementTree> Matchers.expressionStatement(Matcher<ExpressionTree> matcher) Matches anExpressionStatementTreebased on itsExpressionTree.Matchers.hasAnnotation(Class<? extends Annotation> inputClass) Determines whether an expression has an annotation of the given class.Matchers.hasAnnotation(String annotationClass) Determines whether an expression has an annotation of the given type.Matchers.hasAnnotation(TypeMirror annotationMirror) Determines if an expression has an annotation referred to by the given mirror.static Matcher<MethodTree> Matchers.hasAnnotationOnAnyOverriddenMethod(String annotationClass) Matches if a method or any method it overrides has an annotation of the given type.Matchers.hasAnnotationWithSimpleName(String simpleName) Determines whether an expression has an annotation with the given simple name.Matchers.hasAnyAnnotation(Class<? extends Annotation>... annotations) Matchers.hasAnyAnnotation(List<? extends TypeMirror> mirrors) static Matcher<AnnotationTree> Matchers.hasArgumentWithValue(String argumentName, Matcher<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<MethodTree> Matchers.hashCodeMethodDeclaration()MatcheshashCodemethod declaration.Matchers.hasIdentifier(Matcher<IdentifierTree> nodeMatcher) Matches any AST that contains an identifier with a certain property.InjectMatchers.hasInjectAnnotation()Matchers.hasMethod(Matcher<MethodTree> methodMatcher) Matches a class in which at least one method matches the given methodMatcher.Matchers.hasModifier(Modifier modifier) Returns true if the Tree node has the expectedModifier.InjectMatchers.hasProvidesAnnotation()static Matcher<ExpressionTree> Matchers.ignoreParens(Matcher<ExpressionTree> innerMatcher) Ignores any number of parenthesis wrapping an expression and then applies the passed matcher to that expression.Matchers.inLoop()Matches if the given tree is inside a loop.static Matcher<ExpressionTree> CompileTimeConstantExpressionMatcher.instance()static <T extends ExpressionTree>
Matcher<T> Matchers.instanceEqualsInvocation()Matches calls to the methodObject.equals(Object)or any override of that method.static Matcher<ExpressionTree> FieldMatchers.instanceField(String className, String fieldName) static Matcher<ExpressionTree> Matchers.instanceHashCodeInvocation()Matches calls to the methodObject.hashCode()or any override of that method.Matchers.inSynchronized()Matches if this Tree is enclosed by either a synchronized block or a synchronized method.static Matcher<ExpressionTree> Matchers.intLiteral(int value) Matches anintliteral with the given value.Matchers.isArrayType()Matches an AST node if its type is an array type.static Matcher<ExpressionTree> Matchers.isBoxedPrimitiveType()Matches an AST node if its type is a boxed primitive type.Matchers.isDirectImplementationOf(String clazz) Matches any node that is directly an implementation, but not extension, of the given Class.Matchers.isEnum()Matches if aClassTreeis an enum declaration.Matchers.isExtensionOf(String clazz) Matches any node that is a direct extension of the given class.static Matcher<VariableTree> Matchers.isField()Matches if aVariableTreeis a field declaration, as opposed to a local variable, enum constant, parameter to a method, etc.Matchers.isInstance(Class<?> klass) Matches if an AST node is an instance of the given class.static Matcher<ExpressionTree> Matchers.isInstanceField()Matches an AST node that represents a non-static field.static Matcher<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<StatementTree> Matchers.isLastStatementInBlock()Matches a statement AST node if the statement is the last statement in the block.static Matcher<ExpressionTree> Matchers.isNonNull()Deprecated.static Matcher<ExpressionTree> Matchers.isNonNullUsingDataflow()Matches if the expression is provably non-null.static Matcher<ExpressionTree> Matchers.isNull()Deprecated.useMatchers.isNullUsingDataflow()instead.static Matcher<ExpressionTree> Matchers.isNullUsingDataflow()Matches if the expression is provably null.Matchers.isPrimitiveArrayType()Matches an AST node if its type is a primitive array type.Matchers.isPrimitiveOrBoxedPrimitiveType()Matches an AST node if its type is a primitive type, or a boxed version of a primitive type.Matchers.isPrimitiveOrVoidType()Matches an AST node if its type is either a primitive type or avoidtype.Matchers.isPrimitiveType()Matches an AST node if its type is a primitive type.Matchers.isRecord()Matches if aClassTreeis arecorddeclaration.Matches an AST node which is the same object reference as the given node.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.Matchers.isSameType(Class<?> clazz) Matches an AST node if it has the same erased type as the given class.Matchers.isSameType(String typeString) Matches an AST node if it has the same erased type as the given type.Matchers.isStatic()Matches an AST node that is static.Matchers.isSubtypeOf(Supplier<com.sun.tools.javac.code.Type> type) Matches an AST node if its type is a subtype of the given type.Matchers.isSubtypeOf(Class<?> clazz) Matches an AST node if its type is a subtype of the given type.Matchers.isSubtypeOf(String typeStr) Matches an AST node if its type is a subtype of the given type.Matchers.isTransient()Matches an AST node that is transient.static Matcher<AnnotationTree> static Matcher<ExpressionTree> Matchers.isVariable()Matches an AST node that represents a local variable or parameter.Matchers.isVoidType()Matches an AST node if its type is avoidtype.Matches an AST node of a given kind, for example, an Annotation or a switch block.Matches an AST node of a given kind, for example, an Annotation or a switch block.static Matcher<StatementTree> Matchers.matchExpressionReturn(Matcher<ExpressionTree> expressionTreeMatcher) Matches theTreeif it returns an expression matchingexpressionTreeMatcher.Matchers.matchSingleStatementBlock(Matcher<StatementTree> statementMatcher) Matches aBlockTreeif it single statement block with statement matchingstatementMatcher.static Matcher<MethodTree> Matchers.methodHasArity(int arity) Matches if the method accepts the given number of arguments.static Matcher<MethodTree> Matchers.methodHasNoParameters()Matches an AST node that represents a method declaration with no parameters.static Matcher<MethodTree> Matchers.methodHasParameters(Matcher<VariableTree>... variableMatcher) Matches an AST node that represents a method declaration, based on the list of variableMatchers.static Matcher<MethodTree> Matchers.methodHasParameters(List<Matcher<VariableTree>> variableMatcher) Matches an AST node that represents a method declaration, based on the list of variableMatchers.static Matcher<MethodTree> Matchers.methodHasVisibility(MethodVisibility.Visibility visibility) static Matcher<ExpressionTree> Matchers.methodInvocation(Matcher<ExpressionTree> methodSelectMatcher) Matches an AST node if it is a method invocation and the method select matchesmethodSelectMatcher.static Matcher<ExpressionTree> Matchers.methodInvocation(Matcher<ExpressionTree> methodSelectMatcher, ChildMultiMatcher.MatchType matchType, Matcher<ExpressionTree> methodArgumentMatcher) Matches an AST node if it is a method invocation and the given matchers match.static Matcher<MethodTree> Matchers.methodIsConstructor()static Matcher<MethodTree> Matchers.methodIsNamed(String methodName) Match a method declaration with a specific name.static Matcher<MethodTree> Matchers.methodNameStartsWith(String prefix) Match a method declaration that starts with a given string.static Matcher<MethodTree> Matchers.methodReturns(Matcher<? super Tree> returnTypeMatcher) static Matcher<MethodTree> Matchers.methodReturns(Supplier<com.sun.tools.javac.code.Type> returnType) static Matcher<ExpressionTree> Matchers.methodReturnsNonNull()Matches a method invocation that is known to never return null.static Matcher<MethodTree> Matchers.methodReturnsNonPrimitiveType()Match a method that returns a non-primitive type.static Matcher<MethodTree> Matchers.methodWithClassAndName(String className, String methodName) Match a method declaration with a specific enclosing class and method name.Matchers.nestingKind(NestingKind kind) Matches an class based on whether it is nested in another class or method.static <T extends StatementTree>
Matcher<T> Matchers.nextStatement(Matcher<StatementTree> matcher) Matches a statement AST node if the following statement in the enclosing block matches the given matcher.static Matcher<ExpressionTree> Matchers.nonNullLiteral()Matches an AST node if it is a literal other than null.Matches an AST node iff it does not match the given matcher.Matchers.nothing()A matcher that matches no AST node.static Matcher<ExpressionTree> Matchers.nullLiteral()Matches an AST node if it is a null literal.Matchers.packageMatches(Predicate<String> predicate) Matches an AST node whose compilation unit's package name matches the given predicate.Matchers.packageMatches(Pattern pattern) Matches an AST node whose compilation unit's package name matches the given pattern.Matchers.packageStartsWith(String prefix) Matches an AST node whose compilation unit starts with this prefix.Matchers.parentNode(Matcher<Tree> treeMatcher) Matches an AST node if its parent node is matched by the given matcher.static <T extends StatementTree>
Matcher<T> Matchers.previousStatement(Matcher<StatementTree> matcher) Matches a statement AST node if the previous statement in the enclosing block matches the given matcher.static Matcher<MethodInvocationTree> Matchers.receiverOfInvocation(Matcher<ExpressionTree> expressionTreeMatcher) static Matcher<? super 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<StatementTree> Matchers.returnStatement(Matcher<? super ExpressionTree> returnedMatcher) Matches areturnstatement where the returned expression is matched by the passedreturnedMatcher.static Matcher<? super MethodInvocationTree> Matchers.sameArgument(int index1, int index2) Matches aMethodInvocationwhen the arguments at the two given indices are both the same variable, as determined byASTHelpers.sameVariable(ExpressionTree, ExpressionTree).static Matcher<ExpressionTree> Matchers.sameVariable(ExpressionTree expr) Matches if this ExpressionTree refers to the same variable as the one passed into the matcher.static Matcher<MethodTree> Matchers.singleStatementReturnMatcher(Matcher<ExpressionTree> expressionTreeMatcher) Returns a matcher forMethodTreewhose implementation contains a single return statement with expression matching the passedexpressionTreeMatcher.static <T extends ExpressionTree>
Matcher<T> Matchers.staticEqualsInvocation()Matches an invocation of a recognized static object equality method such asObjects.equals(Object, Object).static Matcher<ExpressionTree> FieldMatchers.staticField(String className, String fieldName) static Matcher<ExpressionTree> Matchers.staticFieldAccess()Matches an AST node which is an expression yielding the indicated static field access.static Matcher<ExpressionTree> Matchers.stringLiteral(String value) Matches a Literal AST node if it is a string literal with the given value.static Matcher<ExpressionTree> Matchers.stringLiteral(Pattern pattern) Matches a Literal AST node if it is a string literal which matches the givenPattern.Matchers.symbolHasAnnotation(Class<? extends Annotation> inputClass) Determines whether an expression refers to a symbol that has an annotation of the given type.Matchers.symbolHasAnnotation(String annotationClass) Determines whether an expression refers to a symbol that has an annotation of the given type.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<StatementTree> Matchers.throwStatement(Matcher<? super ExpressionTree> thrownMatcher) Matches athrowstatement where the thrown item is matched by the passedthrownMatcher.static Matcher<MethodTree> Matchers.toStringMethodDeclaration()MatchesObject.toString()method declaration.Converts the given matcher to one that can be applied to any tree but is only executed when run on a tree oftypeand returnsfalsefor all other tree types.static Matcher<TypeCastTree> Matchers.typeCast(Matcher<Tree> typeMatcher, Matcher<ExpressionTree> expressionMatcher) Matches a type cast AST node if both of the given matchers match.Matchers.typePredicateMatcher(TypePredicate pred) Match a Tree based solely on the type produced byASTHelpers.getType(Tree).static Matcher<VariableTree> Matchers.variableInitializer(Matcher<ExpressionTree> expressionTreeMatcher) Matches on the initializer of a VariableTree AST node.static Matcher<VariableTree> Matchers.variableType(Matcher<Tree> treeMatcher) Matches on the type of a VariableTree AST node.Methods in com.google.errorprone.matchers with parameters of type MatcherModifier and TypeMethodDescriptionCompose several matchers together, such that the composite matches an AST node iff all the given matchers do.static <T extends Tree>
MultiMatcher<T, AnnotationTree> Matchers.annotations(ChildMultiMatcher.MatchType matchType, Matcher<AnnotationTree> annotationMatcher) Matches if the given annotation matcher matches all of or any of the annotations on this tree node.static Matcher<MethodInvocationTree> Matchers.argument(int position, Matcher<ExpressionTree> argumentMatcher) static Matcher<AssertTree> Matchers.assertionWithCondition(Matcher<ExpressionTree> conditionMatcher) Matches an assertion AST node if the given matcher matches its condition.static Matcher<StatementTree> Matchers.assertStatement(Matcher<ExpressionTree> conditionMatcher) Matches anassertstatement where the condition is matched by the passedconditionMatcher.static Matcher<AssignmentTree> Matchers.assignment(Matcher<ExpressionTree> variableMatcher, Matcher<? super ExpressionTree> expressionMatcher) Matches an assignment operator AST node if both of the given matchers match.static Matcher<BinaryTree> Matchers.binaryTree(Matcher<ExpressionTree> matcher1, Matcher<ExpressionTree> matcher2) Matches a binary tree if the given matchers match the operands in either order.static Matcher<ExpressionTree> Matchers.classLiteral(Matcher<? super ExpressionTree> classMatcher) Matches a class literal with the given class matcher.static CompoundAssignmentMatchers.compoundAssignment(Tree.Kind operator, Matcher<ExpressionTree> leftOperandMatcher, Matcher<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 CompoundAssignmentMatchers.compoundAssignment(Set<Tree.Kind> operators, Matcher<ExpressionTree> receiverMatcher, Matcher<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<ClassTree, MethodTree> Matchers.constructor(ChildMultiMatcher.MatchType matchType, Matcher<MethodTree> constructorMatcher) Matches a class in which any of/all of its constructors match the given constructorMatcher.Applies the given matcher recursively to all descendants of an AST node, and matches if any matching descendant node is found.Applies the given matcher recursively to all descendants of an AST node, and matches if any matching descendant node is found.static <T extends Tree>
Enclosing.Block<T> Matchers.enclosingBlock(Matcher<BlockTree> matcher) Matches an AST node which is enclosed by a block node that matches the given matcher.static <T extends Tree>
Enclosing.Class<T> Matchers.enclosingClass(Matcher<ClassTree> matcher) Matches an AST node which is enclosed by a class node that matches the given matcher.static <T extends Tree>
Enclosing.Method<T> Matchers.enclosingMethod(Matcher<MethodTree> matcher) Matches an AST node which is enclosed by a method node that matches the given matcher.Matchers.enclosingNode(Matcher<Tree> matcher) Matches an AST node that is enclosed by some node that matches the given matcher.static Matcher<EnhancedForLoopTree> Matchers.enhancedForLoop(Matcher<VariableTree> variableMatcher, Matcher<ExpressionTree> expressionMatcher, Matcher<StatementTree> statementMatcher) Matches an enhanced for loop if all the given matchers match.static Matcher<StatementTree> Matchers.expressionStatement(Matcher<ExpressionTree> matcher) Matches anExpressionStatementTreebased on itsExpressionTree.Matchers.hasArguments(ChildMultiMatcher.MatchType matchType, Matcher<ExpressionTree> argumentMatcher) Matches if the given matcher matches all of/any of the arguments to this method invocation.static Matcher<AnnotationTree> Matchers.hasArgumentWithValue(String argumentName, Matcher<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.Matchers.hasIdentifier(Matcher<IdentifierTree> nodeMatcher) Matches any AST that contains an identifier with a certain property.Matchers.hasMethod(Matcher<MethodTree> methodMatcher) Matches a class in which at least one method matches the given methodMatcher.static Matcher<ExpressionTree> Matchers.ignoreParens(Matcher<ExpressionTree> innerMatcher) Ignores any number of parenthesis wrapping an expression and then applies the passed matcher to that expression.static Matcher<StatementTree> Matchers.matchExpressionReturn(Matcher<ExpressionTree> expressionTreeMatcher) Matches theTreeif it returns an expression matchingexpressionTreeMatcher.Matchers.matchSingleStatementBlock(Matcher<StatementTree> statementMatcher) Matches aBlockTreeif it single statement block with statement matchingstatementMatcher.static MultiMatcher<MethodTree, VariableTree> Matchers.methodHasParameters(ChildMultiMatcher.MatchType matchType, Matcher<VariableTree> parameterMatcher) Matches if the given matcher matches all of/any of the parameters to this method.static Matcher<MethodTree> Matchers.methodHasParameters(Matcher<VariableTree>... variableMatcher) Matches an AST node that represents a method declaration, based on the list of variableMatchers.static Matcher<ExpressionTree> Matchers.methodInvocation(Matcher<ExpressionTree> methodSelectMatcher) Matches an AST node if it is a method invocation and the method select matchesmethodSelectMatcher.static Matcher<ExpressionTree> Matchers.methodInvocation(Matcher<ExpressionTree> methodSelectMatcher, ChildMultiMatcher.MatchType matchType, Matcher<ExpressionTree> methodArgumentMatcher) Matches an AST node if it is a method invocation and the given matchers match.static Matcher<MethodTree> Matchers.methodReturns(Matcher<? super Tree> returnTypeMatcher) static <T extends StatementTree>
Matcher<T> Matchers.nextStatement(Matcher<StatementTree> matcher) Matches a statement AST node if the following statement in the enclosing block matches the given matcher.Matches an AST node iff it does not match the given matcher.Matchers.parentNode(Matcher<Tree> treeMatcher) Matches an AST node if its parent node is matched by the given matcher.static <T extends StatementTree>
Matcher<T> Matchers.previousStatement(Matcher<StatementTree> matcher) Matches a statement AST node if the previous statement in the enclosing block matches the given matcher.static Matcher<MethodInvocationTree> Matchers.receiverOfInvocation(Matcher<ExpressionTree> expressionTreeMatcher) static Matcher<StatementTree> Matchers.returnStatement(Matcher<? super ExpressionTree> returnedMatcher) Matches areturnstatement where the returned expression is matched by the passedreturnedMatcher.static Matcher<MethodTree> Matchers.singleStatementReturnMatcher(Matcher<ExpressionTree> expressionTreeMatcher) Returns a matcher forMethodTreewhose implementation contains a single return statement with expression matching the passedexpressionTreeMatcher.static Matcher<StatementTree> Matchers.throwStatement(Matcher<? super ExpressionTree> thrownMatcher) Matches athrowstatement where the thrown item is matched by the passedthrownMatcher.Converts the given matcher to one that can be applied to any tree but is only executed when run on a tree oftypeand returnsfalsefor all other tree types.static Matcher<TypeCastTree> Matchers.typeCast(Matcher<Tree> typeMatcher, Matcher<ExpressionTree> expressionMatcher) Matches a type cast AST node if both of the given matchers match.static Matcher<VariableTree> Matchers.variableInitializer(Matcher<ExpressionTree> expressionTreeMatcher) Matches on the initializer of a VariableTree AST node.static Matcher<VariableTree> Matchers.variableType(Matcher<Tree> treeMatcher) Matches on the type of a VariableTree AST node.Method parameters in com.google.errorprone.matchers with type arguments of type MatcherModifier and TypeMethodDescriptionCompose several matchers together, such that the composite matches an AST node iff all the given matchers do.Compose several matchers together, such that the composite matches an AST node if any of the given matchers do.static Matcher<MethodTree> Matchers.methodHasParameters(List<Matcher<VariableTree>> variableMatcher) Matches an AST node that represents a method declaration, based on the list of variableMatchers.Constructors in com.google.errorprone.matchers with parameters of type MatcherModifierConstructorDescriptionAnnotationHasArgumentWithValue(String element, Matcher<ExpressionTree> valueMatcher) AnnotationMatcher(ChildMultiMatcher.MatchType matchType, Matcher<AnnotationTree> nodeMatcher) Asserts(Matcher<ExpressionTree> expressionMatcher) BlockOrCase(Matcher<BlockTree> blockTreeMatcher, Matcher<CaseTree> caseTreeMatcher) ChildMultiMatcher(ChildMultiMatcher.MatchType matchType, Matcher<N> nodeMatcher) CompoundAssignment(Set<Tree.Kind> operators, Matcher<ExpressionTree> receiverMatcher, Matcher<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<MethodTree> nodeMatcher) HasArguments(ChildMultiMatcher.MatchType matchType, Matcher<ExpressionTree> nodeMatcher) HasIdentifier(Matcher<IdentifierTree> nodeMatcher) Method(Matcher<MethodTree> matcher) MethodHasParameters(ChildMultiMatcher.MatchType matchType, Matcher<VariableTree> nodeMatcher) MethodInvocation(Matcher<ExpressionTree> methodSelectMatcher, ChildMultiMatcher.MatchType matchType, Matcher<ExpressionTree> methodArgumentMatcher) Creates a new matcher for method invocations based on a method select and an argument matcher.MethodInvocationArgument(int position, Matcher<ExpressionTree> argumentMatcher) Returns(Matcher<? super ExpressionTree> returnedMatcher) New matcher for areturnstatement where the returned expression is matched by the passedreturnedMatcher.Throws(Matcher<? super ExpressionTree> thrownMatcher) New matcher for athrowstatement where the thrown item is matched by the passedthrownMatcher. -
Uses of Matcher in com.google.errorprone.matchers.method
Subinterfaces of Matcher in com.google.errorprone.matchers.methodModifier and TypeInterfaceDescriptionstatic interfaceDeprecated.useMatcher<ExpressionTree>instead of referring directly to this type.static interfaceDeprecated.useMatcher<ExpressionTree>instead of referring directly to this type.static interfaceDeprecated.useMatcher<ExpressionTree>instead of referring directly to this type.static interfaceDeprecated.useMatcher<ExpressionTree>instead of referring directly to this type.static interfaceDeprecated.useMatcher<ExpressionTree>instead of referring directly to this type.static interfaceDeprecated.useMatcher<ExpressionTree>instead of referring directly to this type.static interfaceDeprecated.useMatcher<ExpressionTree>instead of referring directly to this type.static interfaceDeprecated.useMatcher<ExpressionTree>instead of referring directly to this type.static interfaceDeprecated.useMatcher<ExpressionTree>instead of referring directly to this type.static interfaceDeprecated.useMatcher<ExpressionTree>instead of referring directly to this type.Methods in com.google.errorprone.matchers.method that return MatcherModifier and TypeMethodDescriptionstatic Matcher<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
Method parameters in com.google.errorprone.util with type arguments of type MatcherModifier and TypeMethodDescriptionstatic @Nullable List<ExpressionTree> ASTHelpers.matchBinaryTree(BinaryTree tree, List<Matcher<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.