Class AbstractTypeAwareCheck
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.api.AutomaticBean
-
- com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
-
- com.puppycrawl.tools.checkstyle.api.AbstractCheck
-
- com.puppycrawl.tools.checkstyle.checks.AbstractTypeAwareCheck
-
- All Implemented Interfaces:
Configurable
,Contextualizable
- Direct Known Subclasses:
JavadocMethodCheck
@Deprecated public abstract class AbstractTypeAwareCheck extends AbstractCheck
Deprecated.Checkstyle is not type aware tool and all Checks derived from this class are potentially unstable.Abstract class that endeavours to maintain type information for the Java file being checked. It provides helper methods for performing type information functions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractTypeAwareCheck.AbstractClassInfo
Deprecated.Contains class'sToken
.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.
-
Field Summary
Fields Modifier and Type Field 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 Summary
Constructors Constructor Description AbstractTypeAwareCheck()
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method 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 ofRuntimeException
orError
.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.-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
destroy, finishTree, getAcceptableTokens, getClassLoader, getDefaultTokens, getFileContents, getLine, getLines, getTabWidth, getTokenNames, init, isCommentNodesRequired, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
-
-
-
-
Field Detail
-
typeParams
private final java.util.Deque<java.util.Map<java.lang.String,AbstractTypeAwareCheck.AbstractClassInfo>> typeParams
Deprecated.Stack of maps for type params.
-
imports
private final java.util.Set<java.lang.String> imports
Deprecated.Imports details.
-
packageFullIdent
private FullIdent packageFullIdent
Deprecated.Full identifier for package of the method.
-
currentClassName
private java.lang.String currentClassName
Deprecated.Name of current class.
-
classResolver
private ClassResolver classResolver
Deprecated.ClassResolver
instance for current tree.
-
logLoadErrors
private boolean logLoadErrors
Deprecated.Whether to log class loading errors to the checkstyle report instead of throwing a RTE.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.
-
suppressLoadErrors
private boolean suppressLoadErrors
Deprecated.Whether to show class loading errors in the checkstyle report. Request ID 1491630
-
-
Method Detail
-
processAST
protected abstract void processAST(DetailAST ast)
Deprecated.Called to process an AST when visiting it.- Parameters:
ast
- the AST to process. Guaranteed to not be PACKAGE_DEF or IMPORT tokens.
-
logLoadError
protected abstract void logLoadError(AbstractTypeAwareCheck.Token ident)
Deprecated.Logs error if unable to load class information. Abstract, should be overridden in subclasses.- Parameters:
ident
- class name for which we can no load class.
-
setLogLoadErrors
public final void setLogLoadErrors(boolean logLoadErrors)
Deprecated.Controls whether to log class loading errors to the checkstyle report instead of throwing a RTE.- Parameters:
logLoadErrors
- true if errors should be logged
-
setSuppressLoadErrors
public final void setSuppressLoadErrors(boolean suppressLoadErrors)
Deprecated.Controls whether to show class loading errors in the checkstyle report.- Parameters:
suppressLoadErrors
- true if errors shouldn't be shown
-
getRequiredTokens
public final int[] getRequiredTokens()
Deprecated.Description copied from class:AbstractCheck
The tokens that this check must be registered for.- Specified by:
getRequiredTokens
in classAbstractCheck
- Returns:
- the token set this must be registered for.
- See Also:
TokenTypes
-
beginTree
public void beginTree(DetailAST rootAST)
Deprecated.Description copied from class:AbstractCheck
Called before the starting to process a tree. Ideal place to initialize information that is to be collected whilst processing a tree.- Overrides:
beginTree
in classAbstractCheck
- Parameters:
rootAST
- the root of the tree
-
visitToken
public final void visitToken(DetailAST ast)
Deprecated.Description copied from class:AbstractCheck
Called to process a token.- Overrides:
visitToken
in classAbstractCheck
- Parameters:
ast
- the token to process
-
leaveToken
public final void leaveToken(DetailAST ast)
Deprecated.Description copied from class:AbstractCheck
Called after all the child nodes have been process.- Overrides:
leaveToken
in classAbstractCheck
- Parameters:
ast
- the token leaving
-
isUnchecked
protected static boolean isUnchecked(java.lang.Class<?> exception)
Deprecated.Is exception is unchecked (subclass ofRuntimeException
orError
.- Parameters:
exception
-Class
of exception to check- Returns:
- true if exception is unchecked false if exception is checked
-
isSubclass
protected static boolean isSubclass(java.lang.Class<?> child, java.lang.Class<?> parent)
Deprecated.Checks if one class is subclass of another.- Parameters:
child
-Class
of class which should be childparent
-Class
of class which should be parent- Returns:
- true if aChild is subclass of aParent false otherwise
-
getClassResolver
private ClassResolver getClassResolver()
Deprecated.Returns the current tree's ClassResolver.- Returns:
ClassResolver
for current tree.
-
resolveClass
protected final java.lang.Class<?> resolveClass(java.lang.String resolvableClassName, java.lang.String className)
Deprecated.Attempts to resolve the Class for a specified name.- Parameters:
resolvableClassName
- name of the class to resolveclassName
- name of surrounding class.- Returns:
- the resolved class or
null
if unable to resolve the class.
-
tryLoadClass
protected final java.lang.Class<?> tryLoadClass(AbstractTypeAwareCheck.Token ident, java.lang.String className)
Deprecated.Tries to load class. Logs error if unable.- Parameters:
ident
- name of class which we try to load.className
- name of surrounding class.- Returns:
Class
for a ident.
-
logLoadErrorImpl
protected final void logLoadErrorImpl(int lineNo, int columnNo, java.lang.String msgKey, java.lang.Object... values)
Deprecated.Common implementation for logLoadError() method.- Parameters:
lineNo
- line number of the problem.columnNo
- column number of the problem.msgKey
- message key to use.values
- values to fill the message out.
-
processPackage
private void processPackage(DetailAST ast)
Deprecated.Collects the details of a package.- Parameters:
ast
- node containing the package details
-
processImport
private void processImport(DetailAST ast)
Deprecated.Collects the details of imports.- Parameters:
ast
- node containing the import details
-
processTypeParams
private void processTypeParams(DetailAST ast)
Deprecated.Process type params (if any) for given class, enum or method.- Parameters:
ast
- class, enum or method to process.
-
processClass
private void processClass(DetailAST ast)
Deprecated.Processes class definition.- Parameters:
ast
- class definition to process.
-
getCurrentClassName
protected final java.lang.String getCurrentClassName()
Deprecated.Returns current class.- Returns:
- name of current class.
-
createClassInfo
protected final AbstractTypeAwareCheck.AbstractClassInfo createClassInfo(AbstractTypeAwareCheck.Token name, java.lang.String surroundingClass)
Deprecated.Creates class info for given name.- Parameters:
name
- name of type.surroundingClass
- name of surrounding class.- Returns:
- class info for given name.
-
findClassAlias
protected final AbstractTypeAwareCheck.AbstractClassInfo findClassAlias(java.lang.String name)
Deprecated.Looking if a given name is alias.- Parameters:
name
- given name- Returns:
- ClassInfo for alias if it exists, null otherwise
-
-