Package org.codehaus.groovy.syntax
Class CSTNode
java.lang.Object
org.codehaus.groovy.syntax.CSTNode
An abstract base class for nodes in the concrete syntax tree that is
 the result of parsing.  Note that the CSTNode is inextricably linked
 with the Token in that every CSTNode has a Token as its root.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionAdds an element to the node.voidaddChildrenOf(CSTNode of) Adds all children of the specified node to this one.abstract ReductionCreates aReductionfrom this node.booleancanMean(int type) Returns true if the node can be coerced to the specified type.intchildren()Returns the number of non-root elements in the node.abstract CSTNodeget(int index) Returns the specified element, or null.get(int index, boolean safe) Returns the specified element, or Token.NULL if safe is set and the specified element is null (or doesn't exist).Returns a description of the node.intReturns the meaning of this node.intgetMeaningAs(int[] types) Returns the first matching meaning of the specified types.abstract TokengetRoot()Returns the root of the node.getRoot(boolean safe) Returns the root of the node, the Token that indicates its type.Returns the text of the root.intReturns the starting column of the node.intReturns the starting line of the node.intgetType()Returns the actual type of the node.booleanReturns true if the node has any non-root elements.booleanisA(int type) Returns true if the node's meaning matches the specified type.booleanisAllOf(int[] types) Returns true if the node's meaning matches all of the specified types.booleanReturns true if the node is a complete expression.booleanisEmpty()Returns true if the node is completely empty (no root, even).booleanisOneOf(int[] types) Returns true if the node's meaning matches any of the specified types.voidMarks the node a complete expression.Sets an element node in at the specified index.setMeaning(int meaning) Sets the meaning for this node (and its root Token).abstract intsize()Returns the number of elements in the node (including root).toString()Formats the node as aStringand returns it.voidwrite(PrintWriter writer) Formats the node and writes it to the specifiedWriter.protected voidwrite(PrintWriter writer, String indent) Formats the node and writes it to the specifiedWriter.
- 
Constructor Details- 
CSTNodepublic CSTNode()
 
- 
- 
Method Details- 
getMeaningpublic int getMeaning()Returns the meaning of this node. If the node isEmpty(), returns the type of Token.NULL.
- 
setMeaningSets the meaning for this node (and its root Token). Not valid if the node isEmpty(). Returns the node, for convenience.
- 
getTypepublic int getType()Returns the actual type of the node. If the node isEmpty(), returns the type of Token.NULL.
- 
canMeanpublic boolean canMean(int type) Returns true if the node can be coerced to the specified type.
- 
isApublic boolean isA(int type) Returns true if the node's meaning matches the specified type.
- 
isOneOfpublic boolean isOneOf(int[] types) Returns true if the node's meaning matches any of the specified types.
- 
isAllOfpublic boolean isAllOf(int[] types) Returns true if the node's meaning matches all of the specified types.
- 
getMeaningAspublic int getMeaningAs(int[] types) Returns the first matching meaning of the specified types. Returns Types.UNKNOWN if there are no matches.
- 
isEmptypublic boolean isEmpty()Returns true if the node is completely empty (no root, even).
- 
sizepublic abstract int size()Returns the number of elements in the node (including root).
- 
hasChildrenpublic boolean hasChildren()Returns true if the node has any non-root elements.
- 
childrenpublic int children()Returns the number of non-root elements in the node.
- 
getReturns the specified element, or null.
- 
getReturns the specified element, or Token.NULL if safe is set and the specified element is null (or doesn't exist).
- 
getRootReturns the root of the node. By convention, all nodes have a Token as the first element (or root), which indicates the type of the node. May return null if the nodeisEmpty().
- 
getRootReturns the root of the node, the Token that indicates its type. Returns a Token.NULL if safe and the actual root is null.
- 
getRootTextReturns the text of the root. UsesgetRoot(true)to get the root, so you will only receive null in return if the root token returns it.
- 
getDescriptionReturns a description of the node.
- 
getStartLinepublic int getStartLine()Returns the starting line of the node. Returns -1 if not known.
- 
getStartColumnpublic int getStartColumn()Returns the starting column of the node. Returns -1 if not known.
- 
markAsExpressionpublic void markAsExpression()Marks the node a complete expression. Not all nodes support this operation!
- 
isAnExpressionpublic boolean isAnExpression()Returns true if the node is a complete expression.
- 
addAdds an element to the node. Returns the element for convenience. Not all nodes support this operation!
- 
addChildrenOfAdds all children of the specified node to this one. Not all nodes support this operation!
- 
setSets an element node in at the specified index. Returns the element for convenience. Not all nodes support this operation!
- 
asReductionCreates aReductionfrom this node. Returns self if the node is already aReduction.
- 
toStringFormats the node as aStringand returns it.
- 
writeFormats the node and writes it to the specifiedWriter.
- 
writeFormats the node and writes it to the specifiedWriter. The indent is prepended to each output line, and is increased for each recursion.
 
-