Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.puppycrawl.tools.checkstyle.api
Class DetailAST  view DetailAST download DetailAST.java

java.lang.Object
  extended byantlr.BaseAST
      extended byantlr.CommonAST
          extended bycom.puppycrawl.tools.checkstyle.api.DetailAST
All Implemented Interfaces:
antlr.collections.AST, java.io.Serializable

public final class DetailAST
extends antlr.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

Field Summary
private  java.util.BitSet mBranchTokenTypes
          All token types in this branch.
private  int mChildCount
          number of children
private  int mColumnNo
          the column number
private  int mLineNo
          the line number
private  DetailAST mParent
          the parent token
private static int NOT_INITIALIZED
          constant to indicate if not calculated the child count
 
Fields inherited from class antlr.CommonAST
 
Fields inherited from class antlr.BaseAST
down, right
 
Constructor Summary
DetailAST()
           
 
Method Summary
 void addChild(antlr.collections.AST aAST)
          Adds new child to AST.
 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.
private  java.util.BitSet getBranchTokenTypes()
           
 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 getLastChild()
           
 int getLineNo()
           
 DetailAST getParent()
          Returns the parent token.
 DetailAST getPreviousSibling()
          Returns the previous sibling or null if no such sibling exists.
 void initialize(antlr.collections.AST aAST)
           
 void initialize(antlr.Token aTok)
           
 void setFirstChild(antlr.collections.AST aAST)
          Sets this AST's first Child.
 void setNextSibling(antlr.collections.AST aAST)
          Sets AST's next sibling.
(package private)  void setParent(DetailAST aParent)
          Set the parent token.
 
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, getFirstChild, getNextSibling, removeChildren, setVerboseStringConversion, toString, toStringList, toStringTree, xmlSerialize, xmlSerializeNode, xmlSerializeRootClose, xmlSerializeRootOpen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NOT_INITIALIZED

private static final int NOT_INITIALIZED
constant to indicate if not calculated the child count

See Also:
Constant Field Values

mLineNo

private int mLineNo
the line number


mColumnNo

private int mColumnNo
the column number


mChildCount

private int mChildCount
number of children


mParent

private DetailAST mParent
the parent token


mBranchTokenTypes

private java.util.BitSet mBranchTokenTypes
All token types in this branch. Token 'x' (where x is an int) is in this branch if mBranchTokenTypes.get(x) is true.

Constructor Detail

DetailAST

public DetailAST()
Method Detail

initialize

public void initialize(antlr.Token aTok)

initialize

public void initialize(antlr.collections.AST aAST)

setFirstChild

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


setNextSibling

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


addChild

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


getChildCount

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


setParent

void setParent(DetailAST aParent)
Set the parent token.


getParent

public DetailAST getParent()
Returns the parent token.


getLineNo

public int getLineNo()

getColumnNo

public int getColumnNo()

getLastChild

public DetailAST getLastChild()

getBranchTokenTypes

private java.util.BitSet getBranchTokenTypes()

branchContains

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


getChildCount

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


getPreviousSibling

public DetailAST getPreviousSibling()
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.