public abstract class Node extends Object implements Cloneable
Modifier and Type | Field and Description |
---|---|
static int |
ABSOLUTE_BEGIN_LINE |
static int |
ABSOLUTE_END_LINE |
static Comparator<Node> |
NODE_BY_BEGIN_POSITION
This can be used to sort nodes on position.
|
Modifier and Type | Method and Description |
---|---|
abstract <R,A> R |
accept(GenericVisitor<R,A> v,
A arg)
Accept method for visitor support.
|
abstract <A> void |
accept(VoidVisitor<A> v,
A arg)
Accept method for visitor support.
|
void |
addOrphanComment(Comment comment) |
Node |
clone() |
boolean |
contains(Node other) |
boolean |
equals(Object obj) |
List<Comment> |
getAllContainedComments()
This is the list of Comment which are contained in the Node either because
they are properly associated to one of its children or because they are floating
around inside the Node
|
Position |
getBegin()
The begin position of this node in the source file.
|
List<Node> |
getChildrenNodes() |
Comment |
getComment()
This is a comment associated with this node.
|
Position |
getEnd()
The end position of this node in the source file.
|
<N extends Node> |
getNodesByType(Class<N> clazz)
Recursively finds all nodes of a certain type.
|
List<Comment> |
getOrphanComments()
This is a list of Comment which are inside the node and are not associated
with any meaningful AST Node.
|
Node |
getParentNode() |
<T> T |
getParentNodeOfType(Class<T> classType) |
Range |
getRange() |
<M> M |
getUserData(UserDataKey<M> key)
Gets user data for this component using the given key.
|
boolean |
hasComment() |
int |
hashCode() |
boolean |
isPositionedAfter(Position position) |
boolean |
isPositionedBefore(Position position) |
boolean |
remove()
Try to remove this node from the parent
|
protected void |
setAsParentNodeOf(List<? extends Node> childNodes) |
protected void |
setAsParentNodeOf(Node childNode) |
Node |
setBegin(Position begin)
Sets the begin position of this node in the source file.
|
Node |
setBlockComment(String comment)
Use this to store additional information to this node.
|
Node |
setComment(Comment comment)
Use this to store additional information to this node.
|
Node |
setEnd(Position end)
Sets the end position of this node in the source file.
|
Node |
setLineComment(String comment)
Use this to store additional information to this node.
|
void |
setParentNode(Node parentNode)
Assign a new parent to this node, removing it
from the list of children of the previous parent, if any.
|
Node |
setRange(Range range) |
<M> void |
setUserData(UserDataKey<M> key,
M object)
Sets user data for this component using the given key.
|
String |
toString()
Return the String representation of this node.
|
String |
toStringWithoutComments() |
void |
tryAddImportToParentCompilationUnit(Class<?> clazz) |
public static Comparator<Node> NODE_BY_BEGIN_POSITION
public static final int ABSOLUTE_BEGIN_LINE
public static final int ABSOLUTE_END_LINE
public Node()
public Node(Range range)
public abstract <R,A> R accept(GenericVisitor<R,A> v, A arg)
R
- the type the return value of the visitorA
- the type the argument passed to the visitorv
- the visitor implementationarg
- the argument passed to the visitorpublic abstract <A> void accept(VoidVisitor<A> v, A arg)
A
- the type the argument passed for the visitorv
- the visitor implementationarg
- any value relevant for the visitorpublic final Comment getComment()
public Position getBegin()
public Position getEnd()
public Node setBegin(Position begin)
public Range getRange()
public Node setRange(Range range)
range
- the range of characters in the source code that this node covers.public final Node setComment(Comment comment)
comment
- to be setpublic final Node setLineComment(String comment)
comment
- to be setpublic final Node setBlockComment(String comment)
comment
- to be setpublic final String toString()
public final String toStringWithoutComments()
public Node getParentNode()
public <T> T getParentNodeOfType(Class<T> classType)
public boolean contains(Node other)
public void addOrphanComment(Comment comment)
public List<Comment> getOrphanComments()
public List<Comment> getAllContainedComments()
public void setParentNode(Node parentNode)
parentNode
- node to be set as parentprotected void setAsParentNodeOf(Node childNode)
public boolean isPositionedAfter(Position position)
public boolean isPositionedBefore(Position position)
public boolean hasComment()
public void tryAddImportToParentCompilationUnit(Class<?> clazz)
public <N extends Node> List<N> getNodesByType(Class<N> clazz)
clazz
- the type of node to find.public <M> M getUserData(UserDataKey<M> key)
M
- The type of the user data.key
- The key for the dataUserDataKey
public <M> void setUserData(UserDataKey<M> key, M object)
UserDataKey
.M
- The type of user datakey
- The singleton key for the user dataobject
- The user data objectIllegalArgumentException
UserDataKey
public boolean remove()
RuntimeException
- if it fails in an unexpected wayCopyright © 2007–2016. All rights reserved.