Class SuppressionInfo

java.lang.Object
com.google.errorprone.SuppressionInfo

@Immutable @CheckReturnValue public class SuppressionInfo extends Object
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.

  • Field Details

  • 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 checker
      suppressedInGeneratedCode - true if this checker instance should be considered suppressed
    • forCompilationUnit

      public SuppressionInfo forCompilationUnit(com.sun.source.tree.CompilationUnitTree tree, VisitorState state)
      Generates the 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.
    • 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 of 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.

      Parameters:
      sym - The Symbol for the AST node currently being scanned
      state - VisitorState for checking the current tree, as well as for getting the SuppressWarnings symbol type.