Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.puppycrawl.tools.checkstyle.checks
Class AbstractTypeAwareCheck

    java.lang.Object
      com.puppycrawl.tools.checkstyle.api.AutomaticBean
          com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
              com.puppycrawl.tools.checkstyle.api.Check
                  com.puppycrawl.tools.checkstyle.checks.AbstractTypeAwareCheck

All Implemented Interfaces:
  Configurable, Contextualizable

Direct Known Subclasses:
  JavadocMethodCheck, RedundantThrowsCheck

    public abstract class AbstractTypeAwareCheck

extends Check

Abstract class that endeavours to maintain type information for the Java file being checked. It provides helper methods for performing type information functions.

Version:
  1.0
Author:
  Oliver Burn

Nested Class Summary
`protected static class` | `AbstractTypeAwareCheck.ClassInfo` Contains class's `Token`.
`protected static class` | `AbstractTypeAwareCheck.Token` Represents text element with location in the text.

Constructor Summary
`AbstractTypeAwareCheck()`

Method Summary
`void` | `beginTree(DetailAST aRootAST)` Called before the starting to process a tree.
`protected AbstractTypeAwareCheck.ClassInfo` | `createClassInfo(AbstractTypeAwareCheck.Token aName, String aSurroundingClass)` Creates class info for given name.
`protected AbstractTypeAwareCheck.ClassInfo` | `findClassAlias(String aName)` Looking if a given name is alias.
`protected String` | `getCurrentClassName()` Returns current class.
`int[]` | `getRequiredTokens()` The tokens that this check must be registered for.
`protected boolean` | `isSubclass(Class aChild, Class aParent)` Checks if one class is subclass of another
`protected boolean` | `isUnchecked(Class aException)` Is exception is unchecked (subclass of `RuntimeException` or `Error`
`protected void` | `leaveAST(DetailAST aAST)` Called when exiting an AST.
`void` | `leaveToken(DetailAST aAST)` Called after all the child nodes have been process.
`protected abstract void` | `logLoadError(AbstractTypeAwareCheck.Token aIdent)` Logs error if unable to load class information.
`protected void` | `logLoadErrorImpl(int aLineNo, int aColumnNo, String aMsgKey, Object[] aValues)` Common implementation for logLoadError() method.
`protected abstract void` | `processAST(DetailAST aAST)` Called to process an AST when visiting it.
`protected Class` | `resolveClass(String aClassName, String aCurrentClass)` Attempts to resolve the Class for a specified name.
`void` | `setLogLoadErrors(boolean aLogLoadErrors)` Controls whether to log class loading errors to the checkstyle report instead of throwing a RTE.
`void` | `setSuppressLoadErrors(boolean aSuppressLoadErrors)` Controls whether to show class loading errors in the checkstyle report.
`protected Class` | `tryLoadClass(AbstractTypeAwareCheck.Token aIdent, String aCurrentClass)` Tries to load class.
`void` | `visitToken(DetailAST aAST)` Called to process a token.

Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check
`destroy, finishTree, getAcceptableTokens, getClassLoader, getDefaultTokens, getFileContents, getLines, getTabWidth, getTokenNames, init, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens`

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
`getId, getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, log, log, 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`

Constructor Detail

### AbstractTypeAwareCheck

    public AbstractTypeAwareCheck()

Method Detail

### setLogLoadErrors

    public final void setLogLoadErrors(boolean aLogLoadErrors)

  Controls whether to log class loading errors to the checkstyle report instead of throwing a RTE.

  Parameters:
    `aLogLoadErrors` - true if errors should be logged

### setSuppressLoadErrors

    public final void setSuppressLoadErrors(boolean aSuppressLoadErrors)

  Controls whether to show class loading errors in the checkstyle report.

  Parameters:
    `aSuppressLoadErrors` - true if errors shouldn't be shown

### processAST

    protected abstract void processAST(DetailAST aAST)

  Called to process an AST when visiting it.

  Parameters:
    `aAST` - the AST to process. Guaranteed to not be PACKAGE_DEF or IMPORT tokens.

### getRequiredTokens

    public final int[] getRequiredTokens()

  The tokens that this check must be registered for.

  Overrides:
    `getRequiredTokens` in class `Check`
  Returns:
    the token set this must be registered for.
  See Also:
    `TokenTypes`

### beginTree

    public void beginTree(DetailAST aRootAST)

  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 final void visitToken(DetailAST aAST)

  Called to process a token.

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

### leaveToken

    public final void leaveToken(DetailAST aAST)

  Called after all the child nodes have been process.

  Overrides:
    `leaveToken` in class `Check`
  Parameters:
    `aAST` - the token leaving

### leaveAST

    protected void leaveAST(DetailAST aAST)

  Called when exiting an AST. A no-op by default, extending classes may choose to override this to augment their processing.

  Parameters:
    `aAST` - the AST we are departing. Guaranteed to not be PACKAGE_DEF, CLASS_DEF, or IMPORT

### isUnchecked

    protected boolean isUnchecked(Class aException)

  Is exception is unchecked (subclass of `RuntimeException` or `Error`

  Parameters:
    `aException` - `Class` of exception to check
  Returns:
    true if exception is unchecked false if exception is checked

### isSubclass

    protected boolean isSubclass(Class aChild,
                                 Class aParent)

  Checks if one class is subclass of another

  Parameters:
    `aChild` - `Class` of class which should be child
    `aParent` - `Class` of class which should be parent
  Returns:
    true if aChild is subclass of aParent false otherwise

### resolveClass

    protected final Class resolveClass(String aClassName,
                                       String aCurrentClass)

  Attempts to resolve the Class for a specified name.

  Parameters:
    `aClassName` - name of the class to resolve
    `aCurrentClass` - name of surrounding class.
  Returns:
    the resolved class or `null` if unable to resolve the class.

### tryLoadClass

    protected final Class tryLoadClass(AbstractTypeAwareCheck.Token aIdent,
                                       String aCurrentClass)

  Tries to load class. Logs error if unable.

  Parameters:
    `aIdent` - name of class which we try to load.
    `aCurrentClass` - name of surrounding class.
  Returns:
    `Class` for a ident.

### logLoadError

    protected abstract void logLoadError(AbstractTypeAwareCheck.Token aIdent)

  Logs error if unable to load class information. Abstract, should be overrided in subclasses.

  Parameters:
    `aIdent` - class name for which we can no load class.

### logLoadErrorImpl

    protected final void logLoadErrorImpl(int aLineNo,
                                          int aColumnNo,
                                          String aMsgKey,
                                          Object[] aValues)

  Common implementation for logLoadError() method.

  Parameters:
    `aLineNo` - line number of the problem.
    `aColumnNo` - column number of the problem.
    `aMsgKey` - message key to use.
    `aValues` - values to fill the message out.

### getCurrentClassName

    protected final String getCurrentClassName()

  Returns current class.

  Returns:
    name of current class.

### createClassInfo

    protected final AbstractTypeAwareCheck.ClassInfo createClassInfo(AbstractTypeAwareCheck.Token aName,
                                                                     String aSurroundingClass)

  Creates class info for given name.

  Parameters:
    `aName` - name of type.
    `aSurroundingClass` - name of surrounding class.
  Returns:
    class infor for given name.

### findClassAlias

    protected final AbstractTypeAwareCheck.ClassInfo findClassAlias(String aName)

  Looking if a given name is alias.

  Parameters:
    `aName` - given name
  Returns:
    ClassInfo for alias if it exists, null otherwise

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Back to the Checkstyle Home Page
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD