com.puppycrawl.tools.checkstyle.checks
public abstract class AbstractTypeAwareCheck extends Check
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractTypeAwareCheck.ClassInfo
Contains class's
Token . |
protected static class |
AbstractTypeAwareCheck.Token
Represents text element with location in the text.
|
Constructor and Description |
---|
AbstractTypeAwareCheck() |
Modifier and Type | Method and Description |
---|---|
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.
|
destroy, finishTree, getAcceptableTokens, getClassLoader, getDefaultTokens, getFileContents, getLines, getTabWidth, getTokenNames, init, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
public final void setLogLoadErrors(boolean aLogLoadErrors)
aLogLoadErrors
- true if errors should be loggedpublic final void setSuppressLoadErrors(boolean aSuppressLoadErrors)
aSuppressLoadErrors
- true if errors shouldn't be shownprotected abstract void processAST(DetailAST aAST)
aAST
- the AST to process. Guaranteed to not be PACKAGE_DEF or
IMPORT tokens.public final int[] getRequiredTokens()
Check
getRequiredTokens
in class Check
TokenTypes
public void beginTree(DetailAST aRootAST)
Check
public final void visitToken(DetailAST aAST)
Check
visitToken
in class Check
aAST
- the token to processpublic final void leaveToken(DetailAST aAST)
Check
leaveToken
in class Check
aAST
- the token leavingprotected void leaveAST(DetailAST aAST)
aAST
- the AST we are departing. Guaranteed to not be PACKAGE_DEF,
CLASS_DEF, or IMPORTprotected boolean isUnchecked(Class<?> aException)
RuntimeException
or Error
aException
- Class
of exception to checkprotected boolean isSubclass(Class<?> aChild, Class<?> aParent)
aChild
- Class
of class
which should be childaParent
- Class
of class
which should be parentprotected final Class<?> resolveClass(String aClassName, String aCurrentClass)
aClassName
- name of the class to resolveaCurrentClass
- name of surrounding class.null
if unable to resolve the class.protected final Class<?> tryLoadClass(AbstractTypeAwareCheck.Token aIdent, String aCurrentClass)
aIdent
- name of class which we try to load.aCurrentClass
- name of surrounding class.Class
for a ident.protected abstract void logLoadError(AbstractTypeAwareCheck.Token aIdent)
aIdent
- class name for which we can no load class.protected final void logLoadErrorImpl(int aLineNo, int aColumnNo, String aMsgKey, Object... aValues)
aLineNo
- line number of the problem.aColumnNo
- column number of the problem.aMsgKey
- message key to use.aValues
- values to fill the message out.protected final String getCurrentClassName()
protected final AbstractTypeAwareCheck.ClassInfo createClassInfo(AbstractTypeAwareCheck.Token aName, String aSurroundingClass)
aName
- name of type.aSurroundingClass
- name of surrounding class.protected final AbstractTypeAwareCheck.ClassInfo findClassAlias(String aName)
aName
- given nameCopyright © 2001-2014. All Rights Reserved.