com.puppycrawl.tools.checkstyle.checks
Class AbstractTypeAwareCheck
- Configurable, Contextualizable
public abstract class AbstractTypeAwareCheck
Abstract class that endeavours to maintain type information for the Java
file being checked. It provides helper methods for performing type
information functions.
Version:
- Oliver Burn
void | beginTree(DetailAST aRootAST)
|
protected String | getCurrentClassName() - Returns current class.
|
protected boolean | isSameType(String aFirst, String aSecond) - Return if two Strings represent the same type, inspecting the
import statements if necessary
|
protected boolean | isShortName(String aShortName, String aFullName) - Calculate if one type name is a shortname for another type name.
|
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
|
void | leaveToken(DetailAST aAST)
|
protected void | logLoadError(FullIdent aIdent) - Logs error if unable to load class information.
|
protected 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.
|
protected Class | tryLoadClass(FullIdent aIdent, String aCurrentClass) - Tries to load class.
|
void | visitToken(DetailAST aAST)
|
beginTree , destroy , finishTree , getAcceptableTokens , getClassLoader , getDefaultTokens , getFileContents , getLines , getRequiredTokens , getTabWidth , getTokenNames , init , leaveToken , log , log , setClassLoader , setFileContents , setMessages , setTabWidth , setTokens , visitToken |
getMessageBundle , getSeverity , getSeverityLevel , log , log , log , log , log , log , log , log , log , log , log , setSeverity |
AbstractTypeAwareCheck
protected AbstractTypeAwareCheck(boolean aProcessClassToken)
Create an object. Unfortunately the behaviouur of this class has
changed and there is no way to maintain binary comatibility with
this class. If you previously had the CLASS_DEF
token in your list you need to pass true
to this
constructor. Otherwise, you need to add the
CLASS_DEF
token to your list and pass
false
to this constructor.
aProcessClassToken
- indicated if subclass wants to be notified
of CLASS tokens.
getCurrentClassName
protected final String getCurrentClassName()
Returns current class.
- name of current class.
isSameType
protected boolean isSameType(String aFirst,
String aSecond)
Return if two Strings represent the same type, inspecting the
import statements if necessary
aFirst
- first type declared in throws clauseaSecond
- second type declared in thros tag
- true iff type names represent the same type
isShortName
protected boolean isShortName(String aShortName,
String aFullName)
Calculate if one type name is a shortname for another type name.
aShortName
- a shorthand, such as IOException
aFullName
- a full name, such as java.io.IOException
- true iff aShortName represents the same type as aFullName
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
logLoadError
protected void logLoadError(FullIdent 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.
processAST
protected 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.
tryLoadClass
protected final Class tryLoadClass(FullIdent 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.
Class
for a ident.