Package org.codehaus.groovy.ast.stmt
Class ExpressionStatement
java.lang.Object
org.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.stmt.Statement
org.codehaus.groovy.ast.stmt.ExpressionStatement
- All Implemented Interfaces:
NodeMetaDataHandler
Represents an expression statement that executes an expression where the return value is ignored.
An expression statement wraps an
Expression for use as a statement in contexts where
an expression must be treated as a statement (e.g., method calls, assignments, or other
side-effect-producing expressions). The expression is evaluated and its result is discarded.-
Constructor Summary
ConstructorsConstructorDescriptionExpressionStatement(Expression expression) Constructs an expression statement with the given expression. -
Method Summary
Modifier and TypeMethodDescriptionReturns the expression executed by this statement.getText()Returns a human-readable text representation of this AST node.voidsetExpression(Expression expression) Sets the expression executed by this statement.toString()voidvisit(GroovyCodeVisitor visitor) Accepts a code visitor for AST traversal and transformation.Methods inherited from class org.codehaus.groovy.ast.stmt.Statement
addStatementAnnotation, addStatementLabel, copyStatementLabels, getStatementAnnotations, getStatementLabel, getStatementLabels, isEmpty, setStatementLabelMethods inherited from class org.codehaus.groovy.ast.ASTNode
copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePositionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.codehaus.groovy.ast.NodeMetaDataHandler
copyNodeMetaData, getNodeMetaData, getNodeMetaData, getNodeMetaData, newMetaDataMap, putNodeMetaData, removeNodeMetaData, setNodeMetaData
-
Constructor Details
-
ExpressionStatement
Constructs an expression statement with the given expression.- Parameters:
expression- theExpressionto execute; must not be null- Throws:
IllegalArgumentException- if the expression is null
-
-
Method Details
-
visit
Description copied from class:ASTNodeAccepts a code visitor for AST traversal and transformation. Subclasses must implement this method to support visitor pattern-based processing. The visitor pattern enables decoupling of AST structure from processing logic.- Overrides:
visitin classASTNode- Parameters:
visitor- theGroovyCodeVisitorto process this node
-
getExpression
Returns the expression executed by this statement.- Returns:
- the
Expression
-
setExpression
Sets the expression executed by this statement.- Parameters:
expression- theExpression
-
getText
Description copied from class:ASTNodeReturns a human-readable text representation of this AST node. Used for debugging and error messages. Default implementation returns a message indicating the representation is not yet implemented for this node type. -
toString
-