public abstract class BugChecker extends Object implements Suppressible, Serializable
BugChecker
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.Constructor and Description |
---|
BugChecker() |
Modifier and Type | Method and Description |
---|---|
Set<String> |
allNames()
Returns all of the name strings that this checker should respect as part of a
@SuppressWarnings annotation. |
protected 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.
|
protected 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.
|
protected 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.
|
static Description.Builder |
buildDescriptionFromChecker(com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition position,
BugChecker checker)
Returns a new builder for
Description s. |
static Description.Builder |
buildDescriptionFromChecker(com.sun.tools.javac.tree.JCTree tree,
BugChecker checker)
Returns a new builder for
Description s. |
static Description.Builder |
buildDescriptionFromChecker(com.sun.source.tree.Tree node,
BugChecker checker)
Returns a new builder for
Description s. |
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() |
protected Description |
describeMatch(com.sun.source.tree.Tree node)
Helper to create a Description for the common case where there is no fix.
|
protected Description |
describeMatch(com.sun.source.tree.Tree node,
Fix fix)
Helper to create a Description for the common case where there is a fix.
|
protected Description |
describeMatch(com.sun.source.tree.Tree node,
Optional<? extends Fix> fix)
Helper to create a Description for the common case where there is an
Optional fix. |
boolean |
equals(Object obj) |
int |
hashCode() |
boolean |
isSuppressed(com.sun.tools.javac.code.Symbol symbol)
Returns true if the given symbol is annotated with a
@SuppressWarnings that disables
this bug checker. |
boolean |
isSuppressed(com.sun.source.tree.Tree tree)
Returns true if the given tree is annotated with a
@SuppressWarnings that disables this
bug checker. |
String |
linkUrl() |
String |
message() |
BugPattern.SeverityLevel |
severity(Map<String,BugPattern.SeverityLevel> severities) |
boolean |
supportsSuppressWarnings()
Returns true if this checker can be suppressed using
@SuppressWarnings . |
@CheckReturnValue protected Description describeMatch(com.sun.source.tree.Tree node, Fix fix)
@CheckReturnValue protected Description describeMatch(com.sun.source.tree.Tree node)
@CheckReturnValue protected Description describeMatch(com.sun.source.tree.Tree node, Optional<? extends Fix> fix)
Optional
fix.@CheckReturnValue protected Description.Builder buildDescription(com.sun.source.tree.Tree node)
@CheckReturnValue protected Description.Builder buildDescription(com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition position)
@CheckReturnValue protected Description.Builder buildDescription(com.sun.tools.javac.tree.JCTree tree)
@CheckReturnValue public static Description.Builder buildDescriptionFromChecker(com.sun.source.tree.Tree node, BugChecker checker)
Description
s.node
- the node where the error ischecker
- the BugChecker
instance that is producing this Description
@CheckReturnValue public static Description.Builder buildDescriptionFromChecker(com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition position, BugChecker checker)
Description
s.position
- the position of the errorchecker
- the BugChecker
instance that is producing this Description
@CheckReturnValue public static Description.Builder buildDescriptionFromChecker(com.sun.tools.javac.tree.JCTree tree, BugChecker checker)
Description
s.tree
- the tree where the error ischecker
- the BugChecker
instance that is producing this Description
public String canonicalName()
Suppressible
canonicalName
in interface Suppressible
public Set<String> allNames()
Suppressible
@SuppressWarnings
annotation.allNames
in interface Suppressible
public String message()
public BugPattern.SeverityLevel defaultSeverity()
public BugPattern.SeverityLevel severity(Map<String,BugPattern.SeverityLevel> severities)
public String linkUrl()
public boolean supportsSuppressWarnings()
Suppressible
@SuppressWarnings
.supportsSuppressWarnings
in interface Suppressible
public Set<Class<? extends Annotation>> customSuppressionAnnotations()
Suppressible
customSuppressionAnnotations
in interface Suppressible
public boolean isSuppressed(com.sun.source.tree.Tree tree)
@SuppressWarnings
that disables this
bug checker.public boolean isSuppressed(com.sun.tools.javac.code.Symbol symbol)
@SuppressWarnings
that disables
this bug checker.Copyright © 2018. All rights reserved.