Package org.codehaus.groovy.ast.expr

# Class RangeExpression

java.lang.Object
org.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.AnnotatedNode
org.codehaus.groovy.ast.expr.Expression
org.codehaus.groovy.ast.expr.RangeExpression

All Implemented Interfaces:
  `GroovydocHolder<AnnotatedNode>`, `NodeMetaDataHandler`

public class RangeExpression extends Expression
Represents a range expression for creating range objects with bounded endpoints. Supports inclusive ranges (e.g., `0..10`) and exclusive ranges (e.g., `0..<10` or `<0..10`). Range expressions are commonly used in for-loops (e.g., `for (i in 0..10)`) and other iteration contexts. The type of a range expression is always `ClassHelper.RANGE_TYPE`.

- ## Field Summary

  ### Fields inherited from class org.codehaus.groovy.ast.expr.Expression

  `EMPTY_ARRAY`

  ### Fields inherited from interface groovy.lang.groovydoc.GroovydocHolder

  `DOC_COMMENT`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RangeExpression(Expression from, Expression to, boolean inclusive)`
  Creates an inclusive or exclusive range expression.
  `RangeExpression(Expression from, Expression to, boolean exclusiveLeft, boolean exclusiveRight)`
  Creates a range expression with full control over inclusivity of both endpoints.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Expression`
  `getFrom()`
  Returns the starting expression of the range.
  `String`
  `getText()`
  Returns a human-readable text representation of this AST node.
  `Expression`
  `getTo()`
  Returns the ending expression of the range.
  `boolean`
  `isExclusiveLeft()`
  Indicates whether the left endpoint is exclusive (uses `<..`).
  `boolean`
  `isExclusiveRight()`
  Indicates whether the right endpoint is exclusive (uses `..<`).
  `boolean`
  `isInclusive()`
  Indicates whether this is an inclusive range (no exclusion on the right endpoint).
  `Expression`
  `transformExpression(ExpressionTransformer transformer)`
  Transforms this expression and any nested expressions according to the provided transformer.
  `void`
  `visit(GroovyCodeVisitor visitor)`
  Accepts a code visitor for AST traversal and transformation.

  ### Methods inherited from class org.codehaus.groovy.ast.expr.Expression

  `getType, setType, transformExpressions, transformExpressions`

  ### Methods inherited from class org.codehaus.groovy.ast.AnnotatedNode

  `addAnnotation, addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, getGroovydoc, getInstance, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic`

  ### Methods inherited from class org.codehaus.groovy.ast.ASTNode

  `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.codehaus.groovy.ast.NodeMetaDataHandler

  `copyNodeMetaData, getNodeMetaData, getNodeMetaData, getNodeMetaData, newMetaDataMap, putNodeMetaData, removeNodeMetaData, setNodeMetaData`

- ## Constructor Details

  - ### RangeExpression

    public RangeExpression(Expression from, Expression to, boolean inclusive)
    Creates an inclusive or exclusive range expression.
    Parameters:
      `from` - the starting expression (non-null)
      `to` - the ending expression (non-null)
      `inclusive` - true for inclusive range (no exclusion), false for exclusive right endpoint

  - ### RangeExpression

    public RangeExpression(Expression from, Expression to, boolean exclusiveLeft, boolean exclusiveRight)
    Creates a range expression with full control over inclusivity of both endpoints.
    Parameters:
      `from` - the starting expression (non-null)
      `to` - the ending expression (non-null)
      `exclusiveLeft` - true if the left endpoint should be excluded (using `<..`)
      `exclusiveRight` - true if the right endpoint should be excluded (using `..<`)

- ## Method Details

  - ### visit

    public void visit(GroovyCodeVisitor visitor)
    Description copied from class: `ASTNode`
    Accepts 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:
      `visit` in class `ASTNode`
    Parameters:
      `visitor` - the `GroovyCodeVisitor` to process this node

  - ### transformExpression

    public Expression transformExpression(ExpressionTransformer transformer)
    Description copied from class: `Expression`
    Transforms this expression and any nested expressions according to the provided transformer. This method is called during AST transformation phases and must recursively transform any nested expressions to support full AST tree transformation.
    Specified by:
      `transformExpression` in class `Expression`
    Parameters:
      `transformer` - the `ExpressionTransformer` to apply
    Returns:
      a transformed copy of this expression (or this expression itself if no changes are needed)

  - ### getFrom

    public Expression getFrom()
    Returns the starting expression of the range.
    Returns:
      the from expression

  - ### getTo

    public Expression getTo()
    Returns the ending expression of the range.
    Returns:
      the to expression

  - ### isInclusive

    public boolean isInclusive()
    Indicates whether this is an inclusive range (no exclusion on the right endpoint).
    Returns:
      true if the range is inclusive on the right, false if exclusive

  - ### isExclusiveLeft

    public boolean isExclusiveLeft()
    Indicates whether the left endpoint is exclusive (uses `<..`).
    Returns:
      true if the left endpoint is excluded, false otherwise

  - ### isExclusiveRight

    public boolean isExclusiveRight()
    Indicates whether the right endpoint is exclusive (uses `..<`).
    Returns:
      true if the right endpoint is excluded, false otherwise

  - ### getText

    public String getText()
    Description copied from class: `ASTNode`
    Returns 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.
    Overrides:
      `getText` in class `ASTNode`
    Returns:
      text representation of this node, or placeholder for unimplemented types