Reduction (Groovy 5.0.0)

Package: org.codehaus.groovy.syntax

## [Java] Class Reduction

- 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
    Modifiers | Name | Description
    --- | --- | ---
    `static Reduction` | `EMPTY` |

  - ### Constructor Summary

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

  - ### Methods Summary

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

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class CSTNode` | `add, addChildrenOf, asReduction, canMean, children, get, get, getDescription, getMeaning, getMeaningAs, getRoot, getRoot, getRootText, getStartColumn, getStartLine, getType, hasChildren, isA, isAllOf, isAnExpression, isEmpty, isOneOf, markAsExpression, set, setMeaning, size, toString, write, write`

- - ### Field Detail

    - #### public static final Reduction EMPTY

  - ### Constructor Detail

    - #### public Reduction(Token root)

      Initializes the `Reduction` with the specified root.

  - ### Method Detail

    - #### @Override
      public CSTNode add(CSTNode element)

      Adds an element to the node.

    - #### @Override
      public Reduction asReduction()

      Creates a `Reduction` from this node. Returns self if the node is already a `Reduction`.

    - #### @Override
      public CSTNode get(int index)

      Returns the specified element, or null.

    - #### @Override
      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()).

    - #### @Override
      public boolean isAnExpression()

      Returns true if the node is a complete expression.

    - #### @Override
      public boolean isEmpty()

      Returns true if the node is completely empty (no root, even).

    - #### @Override
      public void markAsExpression()

      Marks the node a complete expression.

    - #### public static Reduction newContainer()

      Creates a new `Reduction` with `Token.NULL` as its root.

    - #### public CSTNode remove(int index)

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

    - #### @Override
      public CSTNode set(int index, CSTNode element)

      Sets an element in at the specified index.

    - #### @Override
      public int size()

      Returns the number of elements in the node.