-
InterfaceDescriptionuse
Matcher<ExpressionTree>
instead of referring directly to this type.useMatcher<ExpressionTree>
instead of referring directly to this type.useMatcher<ExpressionTree>
instead of referring directly to this type.useMatcher<ExpressionTree>
instead of referring directly to this type.useMatcher<ExpressionTree>
instead of referring directly to this type.useMatcher<ExpressionTree>
instead of referring directly to this type.useMatcher<ExpressionTree>
instead of referring directly to this type.useMatcher<ExpressionTree>
instead of referring directly to this type.useMatcher<ExpressionTree>
instead of referring directly to this type.
-
MethodDescriptionuse
BugChecker.isSuppressed(Tree, VisitorState)
insteaduseBugChecker.isSuppressed(Symbol, VisitorState)
insteadprefer referring to empty fixes usingSuggestedFix.emptyFix()
.useMatchers.isNonNullUsingDataflow()
instead.useMatchers.isNullUsingDataflow()
instead.The implementation uses javac internals to pretty-print the signatures, and the signature format is not well-specified.IfannotationClass
contains a member that is aClass
or an array of them, attempting to access that member from the Error Prone checker code will result in a runtime exception. Instead, operate ongetSymbol(tree).getAnnotationMirrors()
to meta-syntactically inspect the annotation. Note that this method (and thegetSymbol
-based replacement suggested above) looks for annotations not just on the given tree (such as aMethodTree
) but also on the symbol referred to by the given tree (such as on theSymbol.MethodSymbol
that is being called by the givenMethodInvocationTree
). If you want to examine annotations only on the given tree, then useASTHelpers.getAnnotations(com.sun.source.tree.Tree)
(or a direct call to agetAnnotations
method declared on a specificTree
subclass) instead.IfannotationClass
contains a member that is aClass
or an array of them, attempting to access that member from the Error Prone checker code will result in a runtime exception. Instead, operate onsym.getAnnotationMirrors()
to meta-syntactically inspect the annotation.com.google.errorprone.util.ASTHelpers.hasAnnotation(Tree, Class<? extends Annotation>, VisitorState) preferASTHelpers.hasAnnotation(Symbol, String, VisitorState)
to avoid needing a runtime dependency on the annotation class, and to prevent issues if there is skew between the definition of the annotation on the runtime and compile-time classpathspreferASTHelpers.hasAnnotation(Symbol, String, VisitorState)
to avoid needing a runtime dependency on the annotation class, and to prevent issues if there is skew between the definition of the annotation on the runtime and compile-time classpaths
-
ConstructorDescriptionIf VisitorState is needed, use
VisitorState.createForUtilityPurposes(com.sun.tools.javac.util.Context)
, otherwise just use utility methods in ASTHelpers that don't need VisitorSate.Use the equivalent factory methodVisitorState.createForCustomFindingCollection(com.sun.tools.javac.util.Context, com.google.errorprone.DescriptionListener)
.
Matcher<ExpressionTree>
instead of referring directly to this type.