com.puppycrawl.tools.checkstyle.api
Class DetailAST

java.lang.Object
  extended by antlr.BaseAST
      extended by antlr.CommonAST
          extended by com.puppycrawl.tools.checkstyle.api.DetailAST
All Implemented Interfaces:
AST, Serializable

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, Serialized Form

Field Summary
 
Fields inherited from class antlr.BaseAST
down, right
 
Constructor Summary
DetailAST()
           
 
Method Summary
 void addChild(AST aAST)
           
 boolean branchContains(int aType)
          Checks if this branch of the parse tree contains a token of the provided type.
 DetailAST findFirstToken(int aType)
          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 aType)
          Returns the number of direct child tokens that have the specified type.
 int getColumnNo()
           
 DetailAST getFirstChild()
           
 DetailAST getLastChild()
           
 int getLineNo()
           
 DetailAST getNextSibling()
           
 DetailAST getParent()
          Returns the parent token.
 DetailAST getPreviousSibling()
          Returns the previous sibling or null if no such sibling exists.
 void initialize(AST aAST)
           
 void initialize(Token aTok)
           
 void setFirstChild(AST aAST)
           
 void setNextSibling(AST aAST)
           
 String toString()
           
 
Methods inherited from class antlr.CommonAST
getText, getType, initialize, setText, setType
 
Methods inherited from class antlr.BaseAST
decode, encode, equals, equalsList, equalsListPartial, equalsTree, equalsTreePartial, findAll, findAllPartial, getColumn, getLine, getNumberOfChildren, getTokenNames, removeChildren, setVerboseStringConversion, toStringList, toStringTree, xmlSerialize, xmlSerializeNode, xmlSerializeRootClose, xmlSerializeRootOpen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DetailAST

public DetailAST()
Method Detail

initialize

public void initialize(Token aTok)
Specified by:
initialize in interface AST
Overrides:
initialize in class CommonAST

initialize

public void initialize(AST aAST)
Specified by:
initialize in interface AST
Overrides:
initialize in class CommonAST

setFirstChild

public void setFirstChild(AST aAST)
Specified by:
setFirstChild in interface AST
Overrides:
setFirstChild in class BaseAST

setNextSibling

public void setNextSibling(AST aAST)
Specified by:
setNextSibling in interface AST
Overrides:
setNextSibling in class BaseAST

addChild

public void addChild(AST aAST)
Specified by:
addChild in interface AST
Overrides:
addChild in class BaseAST

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

getParent

public DetailAST getParent()
Returns the parent token.

Returns:
the parent token

getLineNo

public int getLineNo()
Returns:
the line number

getColumnNo

public int getColumnNo()
Returns:
the column number

getLastChild

public DetailAST getLastChild()
Returns:
the last child node

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.

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

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.

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

toString

public String toString()
Specified by:
toString in interface AST
Overrides:
toString in class BaseAST

getNextSibling

public DetailAST getNextSibling()
Specified by:
getNextSibling in interface AST
Overrides:
getNextSibling in class BaseAST

getFirstChild

public DetailAST getFirstChild()
Specified by:
getFirstChild in interface AST
Overrides:
getFirstChild in class BaseAST

Back to the Checkstyle Home Page