Interface DetailAST

  • All Known Implementing Classes:
    DetailAstImpl

    public interface DetailAST
    An interface of Checkstyle's AST nodes for traversing trees generated from the Java code. The main purpose of this interface is to abstract away ANTLR specific classes from API package so other libraries won't require it.
    See Also:
    ANTLR Website
    • Method Detail

      • getChildCount

        int getChildCount()
        Returns the number of child nodes one level below this node. That is, does not recurse down the tree.
        Returns:
        the number of child nodes
      • getChildCount

        int getChildCount​(int type)
        Returns the number of direct child tokens that have the specified type.
        Parameters:
        type - the token type to match
        Returns:
        the number of matching token
      • getText

        String getText()
        Gets the text of this AST.
        Returns:
        the text.
      • getType

        int getType()
        Gets the type of this AST.
        Returns:
        the type.
      • getLineNo

        int getLineNo()
        Gets line number.
        Returns:
        the line number
      • getColumnNo

        int getColumnNo()
        Gets column number.
        Returns:
        the column number
      • branchContains

        @Deprecated(since="8.43")
        boolean branchContains​(int type)
        Deprecated.
        Usage of this method is no longer accepted. We encourage traversal of subtrees to be written per the needs of each check to avoid unintended side effects.
        Checks if this branch of the parse tree contains a token of the provided type.
        Parameters:
        type - a TokenType
        Returns:
        true if and only if this branch (including this node) contains a token of type type.
      • getPreviousSibling

        DetailAST getPreviousSibling()
        Returns the previous sibling or null if no such sibling exists.
        Returns:
        the previous sibling or null if no such sibling exists.
      • findFirstToken

        DetailAST findFirstToken​(int type)
        Returns the first child token that makes a specified type.
        Parameters:
        type - the token type to match
        Returns:
        the matching token, or null if no match
      • getNextSibling

        DetailAST getNextSibling()
        Get the next sibling in line after this one.
        Returns:
        the next sibling or null if none.
      • getFirstChild

        DetailAST getFirstChild()
        Get the first child of this AST.
        Returns:
        the first child or null if none.
      • hasChildren

        boolean hasChildren()
        Returns whether this AST has any children.
        Returns:
        true if this AST has any children.