Reduction (Groovy 5.0.7)
Description: declaration: package: org.codehaus.groovy.syntax, class: Reduction

Package org.codehaus.groovy.syntax

# Class Reduction

java.lang.Object
org.codehaus.groovy.syntax.CSTNode
org.codehaus.groovy.syntax.Reduction

public class Reduction extends CSTNode
A syntax reduction, produced by the `Parser`.

See Also:
  - `Token`
  - `CSTNode`
  - `Types`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Reduction`
  `EMPTY`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Reduction(Token root)`
  Initializes the `Reduction` with the specified root.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `CSTNode`
  `add(CSTNode element)`
  Adds an element to the node.
  `Reduction`
  `asReduction()`
  Creates a `Reduction` from this node.
  `CSTNode`
  `get(int index)`
  Returns the specified element, or null.
  `Token`
  `getRoot()`
  Returns the root of the node, the Token that indicates its type.
  `boolean`
  `isAnExpression()`
  Returns true if the node is a complete expression.
  `boolean`
  `isEmpty()`
  Returns true if the node is completely empty (no root, even).
  `void`
  `markAsExpression()`
  Marks the node a complete expression.
  `static Reduction`
  `newContainer()`
  Creates a new `Reduction` with `Token.NULL` as its root.
  `CSTNode`
  `remove(int index)`
  Removes a node from the `Reduction`.
  `CSTNode`
  `set(int index, CSTNode element)`
  Sets an element in at the specified index.
  `int`
  `size()`
  Returns the number of elements in the node.

  ### Methods inherited from class org.codehaus.groovy.syntax.CSTNode

  `addChildrenOf, canMean, children, get, getDescription, getMeaning, getMeaningAs, getRoot, getRootText, getStartColumn, getStartLine, getType, hasChildren, isA, isAllOf, isOneOf, setMeaning, toString, write, write`

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

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

- ## Field Details

  - ### EMPTY

    public static final Reduction EMPTY

- ## Constructor Details

  - ### Reduction

    public Reduction(Token root)
    Initializes the `Reduction` with the specified root.

- ## Method Details

  - ### newContainer

    public static Reduction newContainer()
    Creates a new `Reduction` with `Token.NULL` as its root.

  - ### isEmpty

    public boolean isEmpty()
    Returns true if the node is completely empty (no root, even).
    Overrides:
      `isEmpty` in class `CSTNode`

  - ### size

    public int size()
    Returns the number of elements in the node.
    Specified by:
      `size` in class `CSTNode`

  - ### get

    public CSTNode get(int index)
    Returns the specified element, or null.
    Specified by:
      `get` in class `CSTNode`

  - ### getRoot

    public Token getRoot()
    Returns the root of the node, the Token that indicates its type. Returns null if there is no root (usually only if the node is a placeholder of some kind -- see isEmpty()).
    Specified by:
      `getRoot` in class `CSTNode`

  - ### markAsExpression

    public void markAsExpression()
    Marks the node a complete expression.
    Overrides:
      `markAsExpression` in class `CSTNode`

  - ### isAnExpression

    public boolean isAnExpression()
    Returns true if the node is a complete expression.
    Overrides:
      `isAnExpression` in class `CSTNode`

  - ### add

    public CSTNode add(CSTNode element)
    Adds an element to the node.
    Overrides:
      `add` in class `CSTNode`

  - ### set

    public CSTNode set(int index, CSTNode element)
    Sets an element in at the specified index.
    Overrides:
      `set` in class `CSTNode`

  - ### remove

    public CSTNode remove(int index)
    Removes a node from the `Reduction`. You cannot remove the root node (index 0).

  - ### asReduction

    public Reduction asReduction()
    Creates a `Reduction` from this node. Returns self if the node is already a `Reduction`.
    Specified by:
      `asReduction` in class `CSTNode`