public class AstNode
extends java.lang.Object
Token
Modifier and Type | Field and Description |
---|---|
protected AstNodeType |
type |
Constructor and Description |
---|
AstNode(AstNodeType type,
java.lang.String name,
Token token) |
AstNode(Token token) |
Modifier and Type | Method and Description |
---|---|
void |
addChild(AstNode child) |
java.util.List<AstNode> |
findChildren(AstNodeType... nodeTypes)
Find the all children having the requested type(s).
|
java.util.List<AstNode> |
findDirectChildren(AstNodeType... nodeTypes)
Find the all children among direct children having the requested type(s).
|
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
|
java.util.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() |
java.lang.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
|
java.lang.String |
getTokenOriginalValue()
Get the Token's original value associated to this AstNode
|
java.util.List<Token> |
getTokens()
Return all tokens contained in this tree node.
|
java.lang.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... types) |
boolean |
isCopyBookOrGeneratedNode() |
boolean |
isNot(AstNodeType... types) |
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 |
previousAstNode()
Get the previous sibling AstNode in the tree and if this node doesn't exist try to get the next AST Node of the parent.
|
AstNode |
previousSibling()
Get the previous sibling AstNode if exists in the tree.
|
void |
setFromIndex(int fromIndex) |
void |
setToIndex(int toIndex) |
java.lang.String |
toString() |
protected final AstNodeType type
public AstNode(Token token)
public AstNode(AstNodeType type, java.lang.String name, Token token)
public AstNode getParent()
parent
- public void addChild(AstNode child)
public boolean hasChildren()
public java.util.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 previousAstNode()
public AstNode nextSibling()
public AstNode previousSibling()
public java.lang.String getTokenValue()
public java.lang.String getTokenOriginalValue()
public Token getToken()
public int getTokenLine()
public boolean hasToken()
public java.lang.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... types)
public boolean isNot(AstNodeType... types)
public AstNode findFirstDirectChild(AstNodeType... nodeTypes)
In the following case, findFirstDirectChild('B') would return 'B2' : A1 |__ C1 | |__ B1 |__ B2 |__ B3
list
- of desired node typespublic AstNode findFirstChild(AstNodeType... nodeTypes)
In the following case, findFirstChild('B') would return 'B1' : A1 |__ C1 | |__ B1 |__ B2 |__ B3
AstNodeType
- list of desired node typespublic AstNode getFirstChild()
public java.util.List<AstNode> findDirectChildren(AstNodeType... nodeTypes)
In the following case, findDirectChildren('B') would return 'B2' and 'B3' : A1 |__ C1 | |__ B1 |__ B2 |__ B3
AstNodeType
- list of desired the node typespublic java.util.List<AstNode> findChildren(AstNodeType... nodeTypes)
In the following case, findChildren('B', 'C') would return 'C1', 'B1', 'B2' and 'B3' : A1 |__ C1 | |__ B1 |__ B2 |__ D1 |__ B3
AstNodeType
- the node typepublic 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 typepublic boolean isCopyBookOrGeneratedNode()
public AstNodeType getType()
public java.util.List<Token> getTokens()
public java.lang.String toString()
toString
in class java.lang.Object
public Token getLastToken()
Copyright © 2012 SonarSource. All Rights Reserved.