@Deprecated public abstract class AbstractTypeAwareCheck extends AbstractCheck
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractTypeAwareCheck.AbstractClassInfo
Deprecated.
Contains class's
Token . |
private static class |
AbstractTypeAwareCheck.ClassAlias
Deprecated.
Represents type param which is "alias" for real type.
|
private static class |
AbstractTypeAwareCheck.RegularClass
Deprecated.
Represents regular classes/enums.
|
protected static class |
AbstractTypeAwareCheck.Token
Deprecated.
Represents text element with location in the text.
|
Modifier and Type | Field and Description |
---|---|
private ClassResolver |
classResolver
Deprecated.
ClassResolver instance for current tree. |
private java.lang.String |
currentClassName
Deprecated.
Name of current class.
|
private java.util.Set<java.lang.String> |
imports
Deprecated.
Imports details.
|
private boolean |
logLoadErrors
Deprecated.
Whether to log class loading errors to the checkstyle report
instead of throwing a RTE.
|
private FullIdent |
packageFullIdent
Deprecated.
Full identifier for package of the method.
|
private boolean |
suppressLoadErrors
Deprecated.
Whether to show class loading errors in the checkstyle report.
|
private java.util.Deque<java.util.Map<java.lang.String,AbstractTypeAwareCheck.AbstractClassInfo>> |
typeParams
Deprecated.
Stack of maps for type params.
|
Constructor and Description |
---|
AbstractTypeAwareCheck()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
beginTree(DetailAST rootAST)
Deprecated.
Called before the starting to process a tree.
|
protected AbstractTypeAwareCheck.AbstractClassInfo |
createClassInfo(AbstractTypeAwareCheck.Token name,
java.lang.String surroundingClass)
Deprecated.
Creates class info for given name.
|
protected AbstractTypeAwareCheck.AbstractClassInfo |
findClassAlias(java.lang.String name)
Deprecated.
Looking if a given name is alias.
|
private ClassResolver |
getClassResolver()
Deprecated.
Returns the current tree's ClassResolver.
|
protected java.lang.String |
getCurrentClassName()
Deprecated.
Returns current class.
|
int[] |
getRequiredTokens()
Deprecated.
The tokens that this check must be registered for.
|
protected static boolean |
isSubclass(java.lang.Class<?> child,
java.lang.Class<?> parent)
Deprecated.
Checks if one class is subclass of another.
|
protected static boolean |
isUnchecked(java.lang.Class<?> exception)
Deprecated.
Is exception is unchecked (subclass of
RuntimeException
or Error . |
void |
leaveToken(DetailAST ast)
Deprecated.
Called after all the child nodes have been process.
|
protected abstract void |
logLoadError(AbstractTypeAwareCheck.Token ident)
Deprecated.
Logs error if unable to load class information.
|
protected void |
logLoadErrorImpl(int lineNo,
int columnNo,
java.lang.String msgKey,
java.lang.Object... values)
Deprecated.
Common implementation for logLoadError() method.
|
protected abstract void |
processAST(DetailAST ast)
Deprecated.
Called to process an AST when visiting it.
|
private void |
processClass(DetailAST ast)
Deprecated.
Processes class definition.
|
private void |
processImport(DetailAST ast)
Deprecated.
Collects the details of imports.
|
private void |
processPackage(DetailAST ast)
Deprecated.
Collects the details of a package.
|
private void |
processTypeParams(DetailAST ast)
Deprecated.
Process type params (if any) for given class, enum or method.
|
protected java.lang.Class<?> |
resolveClass(java.lang.String resolvableClassName,
java.lang.String className)
Deprecated.
Attempts to resolve the Class for a specified name.
|
void |
setLogLoadErrors(boolean logLoadErrors)
Deprecated.
Controls whether to log class loading errors to the checkstyle report
instead of throwing a RTE.
|
void |
setSuppressLoadErrors(boolean suppressLoadErrors)
Deprecated.
Controls whether to show class loading errors in the checkstyle report.
|
protected java.lang.Class<?> |
tryLoadClass(AbstractTypeAwareCheck.Token ident,
java.lang.String className)
Deprecated.
Tries to load class.
|
void |
visitToken(DetailAST ast)
Deprecated.
Called to process a token.
|
destroy, finishTree, getAcceptableTokens, getClassLoader, getDefaultTokens, getFileContents, getLine, getLines, getTabWidth, getTokenNames, init, isCommentNodesRequired, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
private final java.util.Deque<java.util.Map<java.lang.String,AbstractTypeAwareCheck.AbstractClassInfo>> typeParams
private final java.util.Set<java.lang.String> imports
private FullIdent packageFullIdent
private java.lang.String currentClassName
private ClassResolver classResolver
ClassResolver
instance for current tree.private boolean logLoadErrors
Logging errors will avoid stopping checkstyle completely because of a typo in javadoc. However, with modern IDEs that support automated refactoring and generate javadoc this will occur rarely, so by default we assume a configuration problem in the checkstyle classpath and throw an exception.
This configuration option was triggered by bug 1422462.
private boolean suppressLoadErrors
protected abstract void processAST(DetailAST ast)
ast
- the AST to process. Guaranteed to not be PACKAGE_DEF or
IMPORT tokens.protected abstract void logLoadError(AbstractTypeAwareCheck.Token ident)
ident
- class name for which we can no load class.public final void setLogLoadErrors(boolean logLoadErrors)
logLoadErrors
- true if errors should be loggedpublic final void setSuppressLoadErrors(boolean suppressLoadErrors)
suppressLoadErrors
- true if errors shouldn't be shownpublic final int[] getRequiredTokens()
AbstractCheck
getRequiredTokens
in class AbstractCheck
TokenTypes
public void beginTree(DetailAST rootAST)
AbstractCheck
beginTree
in class AbstractCheck
rootAST
- the root of the treepublic final void visitToken(DetailAST ast)
AbstractCheck
visitToken
in class AbstractCheck
ast
- the token to processpublic final void leaveToken(DetailAST ast)
AbstractCheck
leaveToken
in class AbstractCheck
ast
- the token leavingprotected static boolean isUnchecked(java.lang.Class<?> exception)
RuntimeException
or Error
.exception
- Class
of exception to checkprotected static boolean isSubclass(java.lang.Class<?> child, java.lang.Class<?> parent)
child
- Class
of class
which should be childparent
- Class
of class
which should be parentprivate ClassResolver getClassResolver()
ClassResolver
for current tree.protected final java.lang.Class<?> resolveClass(java.lang.String resolvableClassName, java.lang.String className)
resolvableClassName
- name of the class to resolveclassName
- name of surrounding class.null
if unable to resolve the class.protected final java.lang.Class<?> tryLoadClass(AbstractTypeAwareCheck.Token ident, java.lang.String className)
ident
- name of class which we try to load.className
- name of surrounding class.Class
for a ident.protected final void logLoadErrorImpl(int lineNo, int columnNo, java.lang.String msgKey, java.lang.Object... values)
lineNo
- line number of the problem.columnNo
- column number of the problem.msgKey
- message key to use.values
- values to fill the message out.private void processPackage(DetailAST ast)
ast
- node containing the package detailsprivate void processImport(DetailAST ast)
ast
- node containing the import detailsprivate void processTypeParams(DetailAST ast)
ast
- class, enum or method to process.private void processClass(DetailAST ast)
ast
- class definition to process.protected final java.lang.String getCurrentClassName()
protected final AbstractTypeAwareCheck.AbstractClassInfo createClassInfo(AbstractTypeAwareCheck.Token name, java.lang.String surroundingClass)
name
- name of type.surroundingClass
- name of surrounding class.protected final AbstractTypeAwareCheck.AbstractClassInfo findClassAlias(java.lang.String name)
name
- given name