Package org.codehaus.groovy.ast.stmt
Class BreakStatement
java.lang.Object
org.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.stmt.Statement
org.codehaus.groovy.ast.stmt.BreakStatement
- All Implemented Interfaces:
NodeMetaDataHandler
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 Summary
ConstructorsConstructorDescriptionConstructs an unlabeled break statement that exits the innermost enclosing loop or switch.BreakStatement(String label) Constructs a labeled break statement that exits the enclosing loop or switch with the given label. -
Method Summary
Modifier and TypeMethodDescriptiongetLabel()Returns the label associated with this break statement.voidvisit(GroovyCodeVisitor visitor) Accepts a code visitor for AST traversal and transformation.Methods inherited from class org.codehaus.groovy.ast.stmt.Statement
addStatementAnnotation, addStatementLabel, copyStatementLabels, getStatementAnnotations, getStatementLabel, getStatementLabels, isEmpty, setStatementLabelMethods inherited from class org.codehaus.groovy.ast.ASTNode
copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePositionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.codehaus.groovy.ast.NodeMetaDataHandler
copyNodeMetaData, getNodeMetaData, getNodeMetaData, getNodeMetaData, newMetaDataMap, putNodeMetaData, removeNodeMetaData, setNodeMetaData
-
Constructor Details
-
BreakStatement
public BreakStatement()Constructs an unlabeled break statement that exits the innermost enclosing loop or switch. -
BreakStatement
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
Returns the label associated with this break statement.- Returns:
- the label name, or null if this is an unlabeled break statement
-
visit
Description copied from class:ASTNodeAccepts 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:
visitin classASTNode- Parameters:
visitor- theGroovyCodeVisitorto process this node
-