Package org.codehaus.groovy.ast
Class ASTNode
- java.lang.Object
- 
- org.codehaus.groovy.ast.ASTNode
 
- 
- Direct Known Subclasses:
- AnnotatedNode,- AnnotationNode,- GenericsType,- ModuleNode,- Statement
 
 public class ASTNode extends java.lang.ObjectBase class for any AST node. This class supports basic information used in all nodes of the AST:- line and column number information. Usually a node represents a certain area in a text file determined by a starting position and an ending position. For nodes that do not represent this, this information will be -1. A node can also be configured in its line/col information using another node through setSourcePosition(otherNode).
- every node can store meta data. A phase operation or transform can use this to transport arbitrary information to another phase operation or transform. The only requirement is that the other phase operation or transform runs after the part storing the information. If the information transport is done it is strongly recommended to remove that meta data.
- a text representation of this node trough getText(). This was in the past used for assertion messages. Since the usage of power asserts this method will not be called for this purpose anymore and might be removed in future versions of Groovy
 
- 
- 
Constructor SummaryConstructors Constructor Description ASTNode()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcopyNodeMetaData(ASTNode other)Copies all node meta data from the other node to this oneintgetColumnNumber()intgetLastColumnNumber()intgetLastLineNumber()intgetLineNumber()ListHashMapgetMetaDataMap()java.util.Map<?,?>getNodeMetaData()Returns an unmodifiable view of the current node metadata.<T> TgetNodeMetaData(java.lang.Object key)Gets the node meta data.java.lang.StringgetText()java.lang.ObjectputNodeMetaData(java.lang.Object key, java.lang.Object value)Sets the node meta data but allows overwriting values.voidremoveNodeMetaData(java.lang.Object key)Removes a node meta data entry.voidsetColumnNumber(int columnNumber)voidsetLastColumnNumber(int lastColumnNumber)voidsetLastLineNumber(int lastLineNumber)voidsetLineNumber(int lineNumber)voidsetNodeMetaData(java.lang.Object key, java.lang.Object value)Sets the node meta data.voidsetSourcePosition(ASTNode node)Sets the source position using another ASTNode.voidvisit(GroovyCodeVisitor visitor)
 
- 
- 
- 
Method Detail- 
visitpublic void visit(GroovyCodeVisitor visitor) 
 - 
getTextpublic java.lang.String getText() 
 - 
getLineNumberpublic int getLineNumber() 
 - 
setLineNumberpublic void setLineNumber(int lineNumber) 
 - 
getColumnNumberpublic int getColumnNumber() 
 - 
setColumnNumberpublic void setColumnNumber(int columnNumber) 
 - 
getLastLineNumberpublic int getLastLineNumber() 
 - 
setLastLineNumberpublic void setLastLineNumber(int lastLineNumber) 
 - 
getLastColumnNumberpublic int getLastColumnNumber() 
 - 
setLastColumnNumberpublic void setLastColumnNumber(int lastColumnNumber) 
 - 
setSourcePositionpublic void setSourcePosition(ASTNode node) Sets the source position using another ASTNode. The sourcePosition consists of a line/column pair for the start and a line/column pair for the end of the expression or statement- Parameters:
- node- - the node used to configure the position information
 
 - 
getNodeMetaDatapublic <T> T getNodeMetaData(java.lang.Object key) Gets the node meta data.- Parameters:
- key- - the meta data key
- Returns:
- the node meta data value for this key
 
 - 
copyNodeMetaDatapublic void copyNodeMetaData(ASTNode other) Copies all node meta data from the other node to this one- Parameters:
- other- - the other node
 
 - 
setNodeMetaDatapublic void setNodeMetaData(java.lang.Object key, java.lang.Object value)Sets the node meta data.- Parameters:
- key- - the meta data key
- value- - the meta data value
- Throws:
- GroovyBugError- if key is null or there is already meta data under that key
 
 - 
putNodeMetaDatapublic java.lang.Object putNodeMetaData(java.lang.Object key, java.lang.Object value)Sets the node meta data but allows overwriting values.- Parameters:
- key- - the meta data key
- value- - the meta data value
- Returns:
- the old node meta data value for this key
- Throws:
- GroovyBugError- if key is null
 
 - 
removeNodeMetaDatapublic void removeNodeMetaData(java.lang.Object key) Removes a node meta data entry.- Parameters:
- key- - the meta data key
- Throws:
- GroovyBugError- if the key is null
 
 - 
getNodeMetaDatapublic java.util.Map<?,?> getNodeMetaData() Returns an unmodifiable view of the current node metadata.- Returns:
- the node metadata. Always not null.
 
 - 
getMetaDataMappublic ListHashMap getMetaDataMap() 
 
- 
 
-