Abstract class that endeavours to maintain type information for the Java
file being checked. It provides helper methods for performing type
information functions.
findClassAlias
protected final AbstractTypeAwareCheck.ClassInfo findClassAlias(String aName)
Looking if a given name is alias.
- ClassInfo for alias if it exists, null otherwise
getCurrentClassName
protected final String getCurrentClassName()
Returns current class.
isSubclass
protected boolean isSubclass(Class aChild,
Class aParent)
Checks if one class is subclass of another
aChild
- Class
of class
which should be childaParent
- Class
of class
which should be parent
- true if aChild is subclass of aParent
false otherwise
isUnchecked
protected boolean isUnchecked(Class aException)
Is exception is unchecked (subclass of RuntimeException
or Error
aException
- Class
of exception to check
- true if exception is unchecked
false if exception is checked
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.
aAST
- the AST we are departing. Guaranteed to not be PACKAGE_DEF,
CLASS_DEF, or IMPORT
logLoadError
protected abstract void logLoadError(AbstractTypeAwareCheck.Token aIdent)
Logs error if unable to load class information.
Abstract, should be overrided in subclasses.
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.
aLineNo
- line number of the problem.aColumnNo
- column number of the problem.aMsgKey
- message key to use.aValues
- values to fill the message out.
processAST
protected abstract void processAST(DetailAST aAST)
Called to process an AST when visiting it.
aAST
- the AST to process. Guaranteed to not be PACKAGE_DEF or
IMPORT tokens.
resolveClass
protected final Class resolveClass(String aClassName,
String aCurrentClass)
Attempts to resolve the Class for a specified name.
aClassName
- name of the class to resolveaCurrentClass
- name of surrounding class.
- the resolved class or
null
if unable to resolve the class.
setLogLoadErrors
public final void setLogLoadErrors(boolean aLogLoadErrors)
Controls whether to log class loading errors to the checkstyle report
instead of throwing a RTE.
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.
aSuppressLoadErrors
- true if errors shouldn't be shown
tryLoadClass
protected final Class tryLoadClass(AbstractTypeAwareCheck.Token aIdent,
String aCurrentClass)
Tries to load class. Logs error if unable.
aIdent
- name of class which we try to load.aCurrentClass
- name of surrounding class.