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:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
branchContains
(int type) Deprecated.Usage of this method is no longer accepted.findFirstToken
(int type) Returns the first child token that makes a specified type.int
Returns the number of child nodes one level below this node.int
getChildCount
(int type) Returns the number of direct child tokens that have the specified type.int
Gets column number.Get the first child of this AST.Gets the last child node.int
Gets line number.Get the next sibling in line after this one.int
Deprecated.This method will be removed in a future release.Returns the parent token.Returns the previous sibling or null if no such sibling exists.getText()
Gets the text of this AST.int
getType()
Gets the type of this AST.boolean
Returns whether this AST has any children.
-
Method Details
-
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
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
-
getParent
Returns the parent token.- Returns:
- the parent token
-
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
-
getLastChild
Gets the last child node.- Returns:
- the last child node
-
branchContains
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
Returns the previous sibling or null if no such sibling exists.- Returns:
- the previous sibling or null if no such sibling exists.
-
findFirstToken
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
Get the next sibling in line after this one.- Returns:
- the next sibling or null if none.
-
getFirstChild
Get the first child of this AST.- Returns:
- the first child or null if none.
-
getNumberOfChildren
Deprecated.This method will be removed in a future release. UsegetChildCount()
instead.Get number of children of this AST.- Returns:
- the number of children.
-
hasChildren
boolean hasChildren()Returns whether this AST has any children.- Returns:
true
if this AST has any children.
-