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 Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description boolean
branchContains(int type)
Deprecated.Usage of this method is no longer accepted.DetailAST
findFirstToken(int type)
Returns the first child token that makes a specified type.int
getChildCount()
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
getColumnNo()
Gets column number.DetailAST
getFirstChild()
Get the first child of this AST.DetailAST
getLastChild()
Gets the last child node.int
getLineNo()
Gets line number.DetailAST
getNextSibling()
Get the next sibling in line after this one.int
getNumberOfChildren()
Deprecated.This method will be removed in a future release.DetailAST
getParent()
Returns the parent token.DetailAST
getPreviousSibling()
Returns the previous sibling or null if no such sibling exists.String
getText()
Gets the text of this AST.int
getType()
Gets the type of this AST.boolean
hasChildren()
Returns whether this AST has any children.
-
-
-
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
-
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
DetailAST getLastChild()
Gets the last child node.- Returns:
- the last child node
-
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.
-
getNumberOfChildren
@Deprecated(since="8.30") int 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.
-
-