|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sonar.sslr.api.AstNode
public class AstNode
the parser is in charge to construct an abstract syntax tree (AST) which is a tree representation of the abstract syntactic structure of source code. Each node of the tree is an AstNode and each node denotes a construct occurring in the source code which starts at a given Token.
Token
Field Summary | |
---|---|
protected AstNodeType |
type
|
Constructor Summary | |
---|---|
AstNode(AstNodeType type,
String name,
Token token)
|
|
AstNode(Token token)
|
Method Summary | |
---|---|
void |
addChild(AstNode child)
|
String |
dumpSourceCode()
Dump the partial source code covered by this node. |
List<AstNode> |
findChildren(AstNodeType nodeType)
Find the all children having the requested type. |
List<AstNode> |
findDirectChildren(AstNodeType nodeType)
Find the all children among direct children having the requested type. |
AstNode |
findFirstChild(AstNodeType... nodeTypes)
Find the first child among all children and grand-children having one of the requested types. |
AstNode |
findFirstDirectChild(AstNodeType... nodeTypes)
Find the first child among all direct children having one of the requested types. |
AstNode |
findFirstParent(AstNodeType nodeType)
Find the first parent with the desired node type |
AstNode |
getChild(int index)
Get the desired child |
List<AstNode> |
getChildren()
Get the list of children. |
AstNode |
getFirstChild()
Get the first child of this node |
int |
getFromIndex()
|
AstNode |
getLastChild()
Get the last child of this node |
Token |
getLastToken()
|
String |
getName()
|
int |
getNumberOfChildren()
|
AstNode |
getParent()
Get the parent of this node in the tree. |
int |
getToIndex()
|
Token |
getToken()
Get the Token associated to this AstNode |
int |
getTokenLine()
Get the Token's line associated to this AstNode |
List<Token> |
getTokens()
Return all tokens contained in this tree node. |
String |
getTokenValue()
Get the Token's value associated to this AstNode |
AstNodeType |
getType()
|
boolean |
hasChildren()
|
boolean |
hasChildren(AstNodeType... nodeTypes)
|
boolean |
hasDirectChildren(AstNodeType... nodeTypes)
|
boolean |
hasParents(AstNodeType nodeType)
|
boolean |
hasToBeSkippedFromAst()
|
boolean |
hasToken()
|
boolean |
is(AstNodeType type)
|
boolean |
isCopyBookOrGeneratedNode()
|
boolean |
isNot(AstNodeType type)
|
AstNode |
nextAstNode()
Get the next sibling AstNode in the tree and if this node doesn't exist try to get the next AST Node of the parent. |
AstNode |
nextSibling()
Get the next sibling AstNode if exists in the tree. |
AstNode |
previousSibling()
Get the previous sibling AstNode if exists in the tree. |
void |
setAstNodeListener(AstListener action)
|
void |
setFromIndex(int fromIndex)
|
void |
setToIndex(int toIndex)
|
void |
startListening(Object output)
|
void |
stopListening(Object output)
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final AstNodeType type
Constructor Detail |
---|
public AstNode(Token token)
public AstNode(AstNodeType type, String name, Token token)
Method Detail |
---|
public AstNode getParent()
parent
- public void addChild(AstNode child)
public boolean hasChildren()
public List<AstNode> getChildren()
public int getNumberOfChildren()
public AstNode getChild(int index)
index
- the index of the child (start at 0)
public AstNode nextAstNode()
public AstNode nextSibling()
public AstNode previousSibling()
public String getTokenValue()
public Token getToken()
public int getTokenLine()
public boolean hasToken()
public String getName()
public int getFromIndex()
public void setFromIndex(int fromIndex)
public int getToIndex()
public boolean hasToBeSkippedFromAst()
public void setToIndex(int toIndex)
public boolean is(AstNodeType type)
public void setAstNodeListener(AstListener action)
public void startListening(Object output)
public void stopListening(Object output)
public boolean isNot(AstNodeType type)
public AstNode findFirstDirectChild(AstNodeType... nodeTypes)
list
- of desired node types
public AstNode findFirstChild(AstNodeType... nodeTypes)
AstNodeType
- list of desired node types
public AstNode getFirstChild()
public List<AstNode> findDirectChildren(AstNodeType nodeType)
AstNodeType
- the node type
public List<AstNode> findChildren(AstNodeType nodeType)
AstNodeType
- the node type
public AstNode getLastChild()
public boolean hasDirectChildren(AstNodeType... nodeTypes)
public boolean hasChildren(AstNodeType... nodeTypes)
public boolean hasParents(AstNodeType nodeType)
public AstNode findFirstParent(AstNodeType nodeType)
AstNodeType
- the desired Ast node type
public boolean isCopyBookOrGeneratedNode()
public AstNodeType getType()
public String dumpSourceCode()
public List<Token> getTokens()
public String toString()
toString
in class Object
public Token getLastToken()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |