Class BugChecker
- java.lang.Object
-
- com.google.errorprone.bugpatterns.BugChecker
-
- All Implemented Interfaces:
Suppressible
,Serializable
public abstract class BugChecker extends Object implements Suppressible, Serializable
A base class for implementing bug checkers. TheBugChecker
supplies a Scanner implementation for this checker, making it easy to use a single checker. Subclasses should also implement one or more of the*Matcher
interfaces in this class to declare which tree node types to match against.- Author:
- Colin Decker, Eddie Aftandilian ([email protected])
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor Description BugChecker()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Set<String>
allNames()
Returns all of the name strings that this checker should respect as part of a@SuppressWarnings
annotation.Description.Builder
buildDescription(com.sun.source.tree.Tree node)
Returns a Description builder, which allows you to customize the diagnostic with a custom message or multiple fixes.Description.Builder
buildDescription(com.sun.tools.javac.tree.JCTree tree)
Returns a Description builder, which allows you to customize the diagnostic with a custom message or multiple fixes.Description.Builder
buildDescription(com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition position)
Returns a Description builder, which allows you to customize the diagnostic with a custom message or multiple fixes.String
canonicalName()
The canonical name of the check.Set<Class<? extends Annotation>>
customSuppressionAnnotations()
Returns the custom suppression annotations for this checker, if custom suppression is used.BugPattern.SeverityLevel
defaultSeverity()
Description
describeMatch(com.sun.source.tree.Tree node)
Helper to create a Description for the common case where there is no fix.Description
describeMatch(com.sun.source.tree.Tree node, Fix fix)
Helper to create a Description for the common case where there is a fix.Description
describeMatch(com.sun.tools.javac.tree.JCTree node)
Helper to create a Description for the common case where there is no fix.Description
describeMatch(com.sun.tools.javac.tree.JCTree node, Fix fix)
Helper to create a Description for the common case where there is a fix.Description
describeMatch(com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition position)
Helper to create a Description for the common case where there is no fix.Description
describeMatch(com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition position, Fix fix)
Helper to create a Description for the common case where there is a fix.boolean
disableable()
boolean
equals(Object obj)
int
hashCode()
boolean
isSuppressed(com.sun.source.tree.Tree tree)
Deprecated.useisSuppressed(Tree, VisitorState)
insteadboolean
isSuppressed(com.sun.source.tree.Tree tree, VisitorState state)
Returns true if the given tree is annotated with a@SuppressWarnings
that disables this bug checker.boolean
isSuppressed(com.sun.tools.javac.code.Symbol symbol)
Deprecated.useisSuppressed(Symbol, VisitorState)
insteadboolean
isSuppressed(com.sun.tools.javac.code.Symbol sym, VisitorState state)
Returns true if the given symbol is annotated with a@SuppressWarnings
or other annotation that disables this bug checker.String
linkUrl()
String
message()
boolean
supportsSuppressWarnings()
Returns true if this checker can be suppressed using@SuppressWarnings
.boolean
suppressedByAnyOf(Set<com.sun.tools.javac.util.Name> annotations, VisitorState s)
com.google.common.collect.ImmutableRangeSet<Integer>
suppressedRegions(VisitorState state)
Computes a RangeSet of code regions which are suppressed by this bug checker.
-
-
-
Method Detail
-
describeMatch
@CheckReturnValue public Description describeMatch(com.sun.source.tree.Tree node, Fix fix)
Helper to create a Description for the common case where there is a fix.
-
describeMatch
@CheckReturnValue public Description describeMatch(com.sun.tools.javac.tree.JCTree node, Fix fix)
Helper to create a Description for the common case where there is a fix.
-
describeMatch
@CheckReturnValue public Description describeMatch(com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition position, Fix fix)
Helper to create a Description for the common case where there is a fix.
-
describeMatch
@CheckReturnValue public Description describeMatch(com.sun.source.tree.Tree node)
Helper to create a Description for the common case where there is no fix.
-
describeMatch
@CheckReturnValue public Description describeMatch(com.sun.tools.javac.tree.JCTree node)
Helper to create a Description for the common case where there is no fix.
-
describeMatch
@CheckReturnValue public Description describeMatch(com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition position)
Helper to create a Description for the common case where there is no fix.
-
buildDescription
@CheckReturnValue public Description.Builder buildDescription(com.sun.source.tree.Tree node)
Returns a Description builder, which allows you to customize the diagnostic with a custom message or multiple fixes.
-
buildDescription
@CheckReturnValue public Description.Builder buildDescription(com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition position)
Returns a Description builder, which allows you to customize the diagnostic with a custom message or multiple fixes.
-
buildDescription
@CheckReturnValue public Description.Builder buildDescription(com.sun.tools.javac.tree.JCTree tree)
Returns a Description builder, which allows you to customize the diagnostic with a custom message or multiple fixes.
-
canonicalName
public String canonicalName()
Description copied from interface:Suppressible
The canonical name of the check.- Specified by:
canonicalName
in interfaceSuppressible
-
allNames
public Set<String> allNames()
Description copied from interface:Suppressible
Returns all of the name strings that this checker should respect as part of a@SuppressWarnings
annotation.- Specified by:
allNames
in interfaceSuppressible
-
message
public String message()
-
defaultSeverity
public BugPattern.SeverityLevel defaultSeverity()
-
linkUrl
public String linkUrl()
-
supportsSuppressWarnings
public boolean supportsSuppressWarnings()
Description copied from interface:Suppressible
Returns true if this checker can be suppressed using@SuppressWarnings
.- Specified by:
supportsSuppressWarnings
in interfaceSuppressible
-
disableable
public boolean disableable()
-
customSuppressionAnnotations
public Set<Class<? extends Annotation>> customSuppressionAnnotations()
Description copied from interface:Suppressible
Returns the custom suppression annotations for this checker, if custom suppression is used.- Specified by:
customSuppressionAnnotations
in interfaceSuppressible
-
suppressedByAnyOf
public boolean suppressedByAnyOf(Set<com.sun.tools.javac.util.Name> annotations, VisitorState s)
- Specified by:
suppressedByAnyOf
in interfaceSuppressible
-
isSuppressed
@Deprecated public boolean isSuppressed(com.sun.source.tree.Tree tree)
Deprecated.useisSuppressed(Tree, VisitorState)
instead
-
isSuppressed
@Deprecated public boolean isSuppressed(com.sun.tools.javac.code.Symbol symbol)
Deprecated.useisSuppressed(Symbol, VisitorState)
instead
-
isSuppressed
public boolean isSuppressed(com.sun.source.tree.Tree tree, VisitorState state)
Returns true if the given tree is annotated with a@SuppressWarnings
that disables this bug checker.
-
isSuppressed
public boolean isSuppressed(com.sun.tools.javac.code.Symbol sym, VisitorState state)
Returns true if the given symbol is annotated with a@SuppressWarnings
or other annotation that disables this bug checker.
-
suppressedRegions
public com.google.common.collect.ImmutableRangeSet<Integer> suppressedRegions(VisitorState state)
Computes a RangeSet of code regions which are suppressed by this bug checker.
-
-