Class BreakStatement

All Implemented Interfaces:
NodeMetaDataHandler

public class BreakStatement extends Statement
Represents a break statement that terminates execution of a loop or switch statement. When a break statement is encountered, control flow exits the current loop or switch, continuing at the statement following the loop or switch. Labeled break statements can exit outer loops or switch statements.
  • Constructor Details

    • BreakStatement

      public BreakStatement()
      Constructs an unlabeled break statement that exits the innermost enclosing loop or switch.
    • BreakStatement

      public BreakStatement(String label)
      Constructs a labeled break statement that exits the enclosing loop or switch with the given label.
      Parameters:
      label - the name of the label to break to, or null for an unlabeled break
  • Method Details

    • getLabel

      public String getLabel()
      Returns the label associated with this break statement.
      Returns:
      the label name, or null if this is an unlabeled break statement
    • 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