W3cubDocs

/Groovy 3.0

[Java] Class ASTNode

  • org.codehaus.groovy.ast.ASTNode
All Implemented Interfaces and Traits:
NodeMetaDataHandler
public class ASTNode
extends Object
implements NodeMetaDataHandler

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

Methods Summary

Methods
Type Params Return Type Name and description
public void copyNodeMetaData(ASTNode other)
Copies all node meta data from the other node to this one
public int getColumnNumber()
public int getLastColumnNumber()
public int getLastLineNumber()
public int getLineNumber()
public Map<?, ?> getMetaDataMap()
public String getText()
public void setColumnNumber(int columnNumber)
public void setLastColumnNumber(int lastColumnNumber)
public void setLastLineNumber(int lastLineNumber)
public void setLineNumber(int lineNumber)
public void setMetaDataMap(Map<?, ?> metaDataMap)
public void setSourcePosition(ASTNode node)
Sets the source position using another ASTNode.
public void visit(GroovyCodeVisitor visitor)

Inherited Methods Summary

Inherited Methods
Methods inherited from class Name
class Object wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll

Method Detail

public void copyNodeMetaData(ASTNode other)

Copies all node meta data from the other node to this one

Parameters:
other - - the other node

public int getColumnNumber()

public int getLastColumnNumber()

public int getLastLineNumber()

public int getLineNumber()

@Override public Map<?, ?> getMetaDataMap()

public String getText()

public void setColumnNumber(int columnNumber)

public void setLastColumnNumber(int lastColumnNumber)

public void setLastLineNumber(int lastLineNumber)

public void setLineNumber(int lineNumber)

@Override public void setMetaDataMap(Map<?, ?> metaDataMap)

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

public void visit(GroovyCodeVisitor visitor)

© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/3.0.7/html/gapi/org/codehaus/groovy/ast/ASTNode.html