@Immutable @CheckReturnValue public class SuppressionInfo extends Object
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.
Modifier and Type | Class and Description |
---|---|
static class |
SuppressionInfo.SuppressedState |
Modifier and Type | Field and Description |
---|---|
static SuppressionInfo |
EMPTY |
Modifier and Type | Method and Description |
---|---|
SuppressionInfo |
forCompilationUnit(com.sun.source.tree.CompilationUnitTree tree,
VisitorState state)
Generates the
SuppressionInfo for a CompilationUnitTree . |
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.
|
SuppressionInfo |
withExtendedSuppressions(com.sun.tools.javac.code.Symbol sym,
VisitorState state,
Set<? extends com.sun.tools.javac.util.Name> customSuppressionAnnosToLookFor)
Returns an instance of
SuppressionInfo that takes into account any suppression signals
present on sym as well as those already stored in this . |
public static final SuppressionInfo EMPTY
public SuppressionInfo.SuppressedState suppressedState(Suppressible suppressible, boolean suppressedInGeneratedCode, VisitorState state)
suppressible
- Holds information about the suppressibilty of a checkersuppressedInGeneratedCode
- true if this checker instance should be considered suppressedpublic SuppressionInfo forCompilationUnit(com.sun.source.tree.CompilationUnitTree tree, VisitorState state)
SuppressionInfo
for a CompilationUnitTree
. This differs in that
isGenerated
is determined by inspecting the annotations of the outermost class so that
matchers on CompilationUnitTree
will also be suppressed.public SuppressionInfo withExtendedSuppressions(com.sun.tools.javac.code.Symbol sym, VisitorState state, Set<? extends com.sun.tools.javac.util.Name> customSuppressionAnnosToLookFor)
SuppressionInfo
that takes into account any suppression signals
present on sym
as well as those already stored in this
.
Checks suppressions for any @SuppressWarnings
, Android's SuppressLint
, and
custom suppression annotations described by customSuppressionAnnosToLookFor
.
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.
sym
- The Symbol
for the AST node currently being scannedstate
- VisitorState for checking the current tree, as well as for getting the SuppressWarnings symbol type
.Copyright © 2019. All rights reserved.