Class EmptyStatement

All Implemented Interfaces:
NodeMetaDataHandler

public class EmptyStatement extends Statement
Represents an empty statement that performs no operation. An empty statement is a valid statement that can appear wherever a statement is expected but has no executable code. Empty statements are often used as default cases or as placeholders in control flow structures.

An immutable singleton INSTANCE is provided for use when source position or other occurrence-specific metadata is not needed. Using the singleton reduces memory overhead.

  • Field Details

    • INSTANCE

      public static final EmptyStatement INSTANCE
      Immutable singleton that is recommended for use when source range or any other occurrence-specific metadata is not needed. Using this singleton conserves memory by avoiding unnecessary object allocations.
      See Also:
  • Constructor Details

    • EmptyStatement

      public EmptyStatement()
      Constructs a new empty statement instance. For most use cases, consider using INSTANCE instead to avoid unnecessary object allocation.
      See Also:
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Description copied from class: Statement
      Returns true if this statement is empty or produces no side effects. Typically only EmptyStatement returns true.
      Overrides:
      isEmpty in class Statement
      Returns:
      true if this statement is empty
    • 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