Groovy Documentation

## org.codehaus.groovy.ast
[Java] Class ASTNode

    java.lang.Object
      org.codehaus.groovy.ast.ASTNode

    public class ASTNode
    extends java.lang.Object

Base 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

Authors:
  James Strachan

Version:
  \$Revision\$

Method Summary
`void` | `copyNodeMetaData(ASTNode other)` Copies all node meta data from the other node to this one
`int` | `getColumnNumber()`
`int` | `getLastColumnNumber()`
`int` | `getLastLineNumber()`
`int` | `getLineNumber()`
`java.lang.Object` | `getNodeMetaData(java.lang.Object key)` Gets the node meta data.
`java.lang.String` | `getText()`
`java.lang.Object` | `putNodeMetaData(java.lang.Object key, java.lang.Object value)` Sets the node meta data but allows overwriting values.
`void` | `removeNodeMetaData(java.lang.Object key)` Removes a node meta data entry.
`void` | `setColumnNumber(int columnNumber)`
`void` | `setLastColumnNumber(int lastColumnNumber)`
`void` | `setLastLineNumber(int lastLineNumber)`
`void` | `setLineNumber(int lineNumber)`
`void` | `setNodeMetaData(java.lang.Object key, java.lang.Object value)` Sets the node meta data.
`void` | `setSourcePosition(ASTNode node)` Sets the source position using another ASTNode.
`void` | `visit(GroovyCodeVisitor visitor)`

Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Method Detail

### copyNodeMetaData

    public void copyNodeMetaData(ASTNode other)

  Copies all node meta data from the other node to this one
  Parameters:
    `other` - - the other node

### getColumnNumber

    public int getColumnNumber()

### getLastColumnNumber

    public int getLastColumnNumber()

### getLastLineNumber

    public int getLastLineNumber()

### getLineNumber

    public int getLineNumber()

### getNodeMetaData

    public java.lang.Object 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

### getText

    public java.lang.String getText()

### putNodeMetaData

    public java.lang.Object putNodeMetaData(java.lang.Object key, java.lang.Object value)

  Sets the node meta data but allows overwriting values.
  throws:
    GroovyBugError if key is null
  Parameters:
    `key` - - the meta data key
    `value` - - the meta data value
  Returns:
    the old node meta data value for this key

### removeNodeMetaData

    public void removeNodeMetaData(java.lang.Object key)

  Removes a node meta data entry.
  throws:
    GroovyBugError if the key is null
  Parameters:
    `key` - - the meta data key

### setColumnNumber

    public void setColumnNumber(int columnNumber)

### setLastColumnNumber

    public void setLastColumnNumber(int lastColumnNumber)

### setLastLineNumber

    public void setLastLineNumber(int lastLineNumber)

### setLineNumber

    public void setLineNumber(int lineNumber)

### setNodeMetaData

    public void setNodeMetaData(java.lang.Object key, java.lang.Object value)

  Sets the node meta data.
  throws:
    GroovyBugError if key is null or there is already meta data under that key
  Parameters:
    `key` - - the meta data key
    `value` - - the meta data value

### setSourcePosition

    public 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

### visit

    public void visit(GroovyCodeVisitor visitor)

Groovy Documentation