Package org.codehaus.groovy.syntax
Class Reduction
- java.lang.Object
-
- org.codehaus.groovy.syntax.CSTNode
-
- org.codehaus.groovy.syntax.Reduction
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CSTNode
add(CSTNode element)
Adds an element to the node.Reduction
asReduction()
Creates aReduction
from this node.CSTNode
get(int index)
Returns the specified element, or null.Token
getRoot()
Returns the root of the node, the Token that indicates its type.boolean
isAnExpression()
Returns true if the node is a complete expression.boolean
isEmpty()
Returns true if the node is completely empty (no root, even).void
markAsExpression()
Marks the node a complete expression.static Reduction
newContainer()
Creates a newReduction
withToken.NULL
as its root.CSTNode
remove(int index)
Removes a node from theReduction
.CSTNode
set(int index, CSTNode element)
Sets an element in at the specified index.int
size()
Returns the number of elements in the node.-
Methods inherited from class org.codehaus.groovy.syntax.CSTNode
addChildrenOf, canMean, children, get, getDescription, getMeaning, getMeaningAs, getRoot, getRootText, getStartColumn, getStartLine, getType, hasChildren, isA, isAllOf, isOneOf, setMeaning, toString, write, write
-
-
-
-
Field Detail
-
EMPTY
public static final Reduction EMPTY
-
-
Constructor Detail
-
Reduction
public Reduction(Token root)
Initializes theReduction
with the specified root.
-
-
Method Detail
-
newContainer
public static Reduction newContainer()
Creates a newReduction
withToken.NULL
as its root.
-
isEmpty
public boolean isEmpty()
Returns true if the node is completely empty (no root, even).
-
size
public int size()
Returns the number of elements in the node.
-
get
public CSTNode get(int index)
Returns the specified element, or null.
-
getRoot
public Token getRoot()
Returns the root of the node, the Token that indicates its type. Returns null if there is no root (usually only if the node is a placeholder of some kind -- see isEmpty()).
-
markAsExpression
public void markAsExpression()
Marks the node a complete expression.- Overrides:
markAsExpression
in classCSTNode
-
isAnExpression
public boolean isAnExpression()
Returns true if the node is a complete expression.- Overrides:
isAnExpression
in classCSTNode
-
remove
public CSTNode remove(int index)
Removes a node from theReduction
. You cannot remove the root node (index 0).
-
asReduction
public Reduction asReduction()
Creates aReduction
from this node. Returns self if the node is already aReduction
.- Specified by:
asReduction
in classCSTNode
-
-