com.puppycrawl.tools.checkstyle.checks
Class SuppressWarningsHolder

java.lang.Object
  extended by com.puppycrawl.tools.checkstyle.api.AutomaticBean
      extended by com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
          extended by com.puppycrawl.tools.checkstyle.api.Check
              extended by com.puppycrawl.tools.checkstyle.checks.SuppressWarningsHolder
All Implemented Interfaces:
Configurable, Contextualizable

public class SuppressWarningsHolder
extends Check

Maintains a set of check suppressions from SuppressWarnings annotations.

Author:
Trevor Robinson

Field Summary
static String CHECKSTYLE_PREFIX
          Optional prefix for warning suppressions that are only intended to be recognized by checkstyle.
 
Constructor Summary
SuppressWarningsHolder()
           
 
Method Summary
 void beginTree(DetailAST aRootAST)
          Called before the starting to process a tree.
static String getAlias(String aSourceName)
          Returns the alias for the source name of a check.
static String getDefaultAlias(String aSourceName)
          Returns the default alias for the source name of a check, which is the source name in lower case with any dotted prefix or "Check" suffix removed.
 int[] getDefaultTokens()
          Returns the default token a check is interested in.
static boolean isSuppressed(String aSourceName, int aLine, int aColumn)
          Checks for a suppression of a check with the given source name and location in the last file processed.
static void registerAlias(String aSourceName, String aCheckAlias)
          Registers an alias for the source name of a check.
 void setAliasList(String aAliasList)
          Registers a list of source name aliases based on a comma-separated list of source=alias items, such as com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck= paramnum.
 void visitToken(DetailAST aAST)
          Called to process a token.
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check
destroy, finishTree, getAcceptableTokens, getClassLoader, getFileContents, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHECKSTYLE_PREFIX

public static final String CHECKSTYLE_PREFIX
Optional prefix for warning suppressions that are only intended to be recognized by checkstyle. For instance, to suppress FallThroughCheck only in checkstyle (and not in javac), use the suppression "checkstyle:fallthrough". To suppress the warning in both tools, just use "fallthrough".

See Also:
Constant Field Values
Constructor Detail

SuppressWarningsHolder

public SuppressWarningsHolder()
Method Detail

getDefaultAlias

public static String getDefaultAlias(String aSourceName)
Returns the default alias for the source name of a check, which is the source name in lower case with any dotted prefix or "Check" suffix removed.

Parameters:
aSourceName - the source name of the check (generally the class name)
Returns:
the default alias for the given check

getAlias

public static String getAlias(String aSourceName)
Returns the alias for the source name of a check. If an alias has been explicitly registered via registerAlias(String, String), that alias is returned; otherwise, the default alias is used.

Parameters:
aSourceName - the source name of the check (generally the class name)
Returns:
the current alias for the given check

registerAlias

public static void registerAlias(String aSourceName,
                                 String aCheckAlias)
Registers an alias for the source name of a check.

Parameters:
aSourceName - the source name of the check (generally the class name)
aCheckAlias - the alias used in SuppressWarnings annotations

setAliasList

public void setAliasList(String aAliasList)
Registers a list of source name aliases based on a comma-separated list of source=alias items, such as com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck= paramnum.

Parameters:
aAliasList - the list of comma-separated alias assigments

isSuppressed

public static boolean isSuppressed(String aSourceName,
                                   int aLine,
                                   int aColumn)
Checks for a suppression of a check with the given source name and location in the last file processed.

Parameters:
aSourceName - the source name of the check
aLine - the line number of the check
aColumn - the column number of the check
Returns:
whether the check with the given name is suppressed at the given source location

getDefaultTokens

public int[] getDefaultTokens()
Description copied from class: Check
Returns the default token a check is interested in. Only used if the configuration for a check does not define the tokens.

Specified by:
getDefaultTokens in class Check
Returns:
the default tokens
See Also:
TokenTypes

beginTree

public void beginTree(DetailAST aRootAST)
Description copied from class: Check
Called before the starting to process a tree. Ideal place to initialise information that is to be collected whilst processing a tree.

Overrides:
beginTree in class Check
Parameters:
aRootAST - the root of the tree

visitToken

public void visitToken(DetailAST aAST)
Description copied from class: Check
Called to process a token.

Overrides:
visitToken in class Check
Parameters:
aAST - the token to process


Copyright © 2001-2014. All Rights Reserved.