com.puppycrawl.tools.checkstyle.api

Class DetailAST

public final class DetailAST extends CommonAST

An extension of the CommonAST that records the line and column number. The idea was taken from Java Guru FAQ: How can I include line numbers in automatically generated ASTs?.

Version: 1.0

Author: Oliver Burn lkuehne

See Also: ANTLR Website

Method Summary
voidaddChild(AST aAST)
Adds new child to AST.
booleanbranchContains(int aType)
Checks if this branch of the parse tree contains a token of the provided type.
DetailASTfindFirstToken(int aType)
Returns the first child token that makes a specified type.
intgetChildCount()
Returns the number of child nodes one level below this node.
intgetChildCount(int aType)
Returns the number of direct child tokens that have the specified type.
intgetColumnNo()
DetailASTgetLastChild()
intgetLineNo()
DetailASTgetParent()
Returns the parent token.
DetailASTgetPreviousSibling()
Returns the previous sibling or null if no such sibling exists.
voidinitialize(Token aTok)
{@inheritDoc}
voidinitialize(AST aAST)
{@inheritDoc}
voidsetFirstChild(AST aAST)
Sets this AST's first Child.
voidsetNextSibling(AST aAST)
Sets AST's next sibling.
StringtoString()
{@inheritDoc}

Method Detail

addChild

public void addChild(AST aAST)
Adds new child to AST.

Parameters: aAST the new child

branchContains

public boolean branchContains(int aType)
Checks if this branch of the parse tree contains a token of the provided type.

Parameters: aType a TokenType

Returns: true if and only if this branch (including this node) contains a token of type aType.

findFirstToken

public DetailAST findFirstToken(int aType)
Returns the first child token that makes a specified type.

Parameters: aType the token type to match

Returns: the matching token, or null if no match

getChildCount

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

Returns: the number of child nodes

getChildCount

public int getChildCount(int aType)
Returns the number of direct child tokens that have the specified type.

Parameters: aType the token type to match

Returns: the number of matching token

getColumnNo

public int getColumnNo()

Returns: the column number *

getLastChild

public DetailAST getLastChild()

Returns: the last child node

getLineNo

public int getLineNo()

Returns: the line number *

getParent

public DetailAST getParent()
Returns the parent token.

Returns: the parent token

getPreviousSibling

public DetailAST getPreviousSibling()
Returns the previous sibling or null if no such sibling exists.

Returns: the previous sibling or null if no such sibling exists.

initialize

public void initialize(Token aTok)
{@inheritDoc}

initialize

public void initialize(AST aAST)
{@inheritDoc}

setFirstChild

public void setFirstChild(AST aAST)
Sets this AST's first Child.

Parameters: aAST the new first child

setNextSibling

public void setNextSibling(AST aAST)
Sets AST's next sibling.

Parameters: aAST the new next sibling

toString

public String toString()
{@inheritDoc}