Class 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.
    • Constructor Detail

      • AbstractTypeAwareCheck

        public AbstractTypeAwareCheck()
        Deprecated.
    • 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 class AbstractCheck
        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 class AbstractCheck
        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 class AbstractCheck
        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 class AbstractCheck
        Parameters:
        ast - the token leaving
      • isUnchecked

        protected static boolean isUnchecked​(java.lang.Class<?> exception)
        Deprecated.
        Is exception is unchecked (subclass of RuntimeException or Error.
        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 child
        parent - Class of class which should be parent
        Returns:
        true if aChild is subclass of aParent false otherwise
      • 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 resolve
        className - 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.
      • getCurrentClassName

        protected final java.lang.String getCurrentClassName()
        Deprecated.
        Returns current class.
        Returns:
        name of current class.
      • 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