Package: org.codehaus.groovy.control

## [Java] Class LabelVerifier

- org.codehaus.groovy.control.LabelVerifier

-     public class LabelVerifier
      extends PrePostStatementVisitor

  This class checks the handling of labels in the AST

- - ### Constructor Summary

    Constructors
    Constructor and description
    `LabelVerifier(SourceUnit src)` Creates a verifier for label usage in one source unit.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected void` | `assertNoLabelsMissed()` Reports any labeled break or continue statements that could not be matched.
    `` | `protected SourceUnit` | `getSourceUnit()` Returns the source unit currently being verified.
    `` | `protected void` | `postVisitStatement(Statement s)` Removes any labels that go out of scope after visiting the current statement.
    `` | `public void` | `visitBreakStatement(BreakStatement breakStatement)` Verifies that a `break` statement appears in a valid context.
    `` | `protected void` | `visitClassCodeContainer(Statement code)` Resets label-tracking state before verifying a class code block.
    `` | `public void` | `visitContinueStatement(ContinueStatement continueStatement)` Verifies that a `continue` statement appears in a valid loop context.
    `` | `public void` | `visitDoWhileLoop(DoWhileStatement loop)` Verifies labels inside a `do`/`while` loop.
    `` | `public void` | `visitForLoop(ForStatement loop)` Verifies labels inside a `for` loop.
    `` | `public void` | `visitIfElse(IfStatement cond)` Verifies labels inside an `if`/`else` statement.
    `` | `protected void` | `visitStatement(Statement s)` Registers any labels introduced by the current statement.
    `` | `public void` | `visitSwitch(SwitchStatement switchStatement)` Verifies labels inside a `switch` statement.
    `` | `public void` | `visitWhileLoop(WhileStatement loop)` Verifies labels inside a `while` loop.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class PrePostStatementVisitor` | `postVisitStatement, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitContinueStatement, visitDoWhileLoop, visitEmptyStatement, visitExpressionStatement, visitForLoop, visitIfElse, visitReturnStatement, visitStatement, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinally, visitWhileLoop`
    `class ClassCodeVisitorSupport` | `addError, getSourceUnit, visitAnnotation, visitAnnotations, visitAnnotations, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitClass, visitClassCodeContainer, visitClosureExpression, visitConstructor, visitConstructorOrMethod, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitProperty, visitReturnStatement, visitStatement, visitStatementAnnotations, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinally, visitWhileLoop`
    `class CodeVisitorSupport` | `afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitArrayExpression, visitAssertStatement, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBlockStatement, visitBooleanExpression, visitBreakStatement, visitBytecodeExpression, visitCaseStatement, visitCastExpression, visitCatchStatement, visitClassExpression, visitClosureExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitEmptyStatement, visitExpressionStatement, visitFieldExpression, visitForLoop, visitGStringExpression, visitIfElse, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitSwitch, visitSynchronizedStatement, visitTernaryExpression, visitThrowStatement, visitTryCatchFinally, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, visitWhileLoop`

- - ### Constructor Detail

    - #### public LabelVerifier(SourceUnit src)

      Creates a verifier for label usage in one source unit.

      Parameters:
        `src` - the source unit to report errors against

  - ### Method Detail

    - #### protected void assertNoLabelsMissed()

      Reports any labeled break or continue statements that could not be matched.

    - #### protected SourceUnit getSourceUnit()

      Returns the source unit currently being verified.

      Returns:
        the active source unit

    - #### protected void postVisitStatement(Statement s)

      Removes any labels that go out of scope after visiting the current statement.

      Parameters:
        `s` - the statement being exited

    - #### public void visitBreakStatement(BreakStatement breakStatement)

      Verifies that a `break` statement appears in a valid context.

      Parameters:
        `breakStatement` - the break statement to inspect

    - #### protected void visitClassCodeContainer(Statement code)

      Resets label-tracking state before verifying a class code block.

      Parameters:
        `code` - the statement container to verify

    - #### public void visitContinueStatement(ContinueStatement continueStatement)

      Verifies that a `continue` statement appears in a valid loop context.

      Parameters:
        `continueStatement` - the continue statement to inspect

    - #### public void visitDoWhileLoop(DoWhileStatement loop)

      Verifies labels inside a `do`/`while` loop.

      Parameters:
        `loop` - the loop to inspect

    - #### public void visitForLoop(ForStatement loop)

      Verifies labels inside a `for` loop.

      Parameters:
        `loop` - the loop to inspect

    - #### public void visitIfElse(IfStatement cond)

      Verifies labels inside an `if`/`else` statement.

      Parameters:
        `cond` - the conditional statement to inspect

    - #### protected void visitStatement(Statement s)

      Registers any labels introduced by the current statement.

      Parameters:
        `s` - the statement being entered

    - #### public void visitSwitch(SwitchStatement switchStatement)

      Verifies labels inside a `switch` statement.

      Parameters:
        `switchStatement` - the switch statement to inspect

    - #### public void visitWhileLoop(WhileStatement loop)

      Verifies labels inside a `while` loop.

      Parameters:
        `loop` - the loop to inspect