Class SuppressionInfo
java.lang.Object
com.google.errorprone.SuppressionInfo
Immutable container of "suppression signals" - annotations or other information gathered from
source - that can be used to determine if a specific
Suppressible
object should be
considered suppressed.
SuppressionInfo instances are obtained by starting with the EMPTY
instance, then
getting new instances by calling withExtendedSuppressions(com.sun.tools.javac.code.Symbol, com.google.errorprone.VisitorState, java.util.Set<? extends com.sun.tools.javac.util.Name>)
with symbols discovered as you
descend a program tree.
-
Nested Class Summary
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionforCompilationUnit
(com.sun.source.tree.CompilationUnitTree tree, VisitorState state) Generates theSuppressionInfo
for aCompilationUnitTree
.suppressedState
(Suppressible suppressible, boolean suppressedInGeneratedCode, VisitorState state) Returns true if this checker should be considered suppressed given the signals present in this object.withExtendedSuppressions
(com.sun.tools.javac.code.Symbol sym, VisitorState state, Set<? extends com.sun.tools.javac.util.Name> customSuppressionAnnosToLookFor) Returns an instance ofSuppressionInfo
that takes into account any suppression signals present onsym
as well as those already stored inthis
.
-
Field Details
-
EMPTY
-
-
Method Details
-
suppressedState
public SuppressionInfo.SuppressedState suppressedState(Suppressible suppressible, boolean suppressedInGeneratedCode, VisitorState state) Returns true if this checker should be considered suppressed given the signals present in this object.- Parameters:
suppressible
- Holds information about the suppressibilty of a checkersuppressedInGeneratedCode
- true if this checker instance should be considered suppressed
-
forCompilationUnit
public SuppressionInfo forCompilationUnit(com.sun.source.tree.CompilationUnitTree tree, VisitorState state) Generates theSuppressionInfo
for aCompilationUnitTree
. This differs in thatisGenerated
is determined by inspecting the annotations of the outermost class so that matchers onCompilationUnitTree
will also be suppressed. -
withExtendedSuppressions
public SuppressionInfo withExtendedSuppressions(com.sun.tools.javac.code.Symbol sym, VisitorState state, Set<? extends com.sun.tools.javac.util.Name> customSuppressionAnnosToLookFor) Returns an instance ofSuppressionInfo
that takes into account any suppression signals present onsym
as well as those already stored inthis
.Checks suppressions for any
@SuppressWarnings
, Android'sSuppressLint
, and custom suppression annotations described bycustomSuppressionAnnosToLookFor
.We do not modify the existing suppression sets, so they can be restored when moving up the tree. We also avoid copying the suppression sets if the next node to explore does not have any suppressed warnings or custom suppression annotations. This is the common case.
- Parameters:
sym
- TheSymbol
for the AST node currently being scannedstate
- VisitorState for checking the current tree, as well as for getting theSuppressWarnings symbol type
.
-