public class LabelVerifier
extends PrePostStatementVisitor
This class checks the handling of labels in the AST
| Constructor and description |
|---|
LabelVerifier(SourceUnit src)Creates a verifier for label usage in one source unit. |
| 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. |
Creates a verifier for label usage in one source unit.
src - the source unit to report errors againstReports any labeled break or continue statements that could not be matched.
Returns the source unit currently being verified.
Removes any labels that go out of scope after visiting the current statement.
s - the statement being exited Verifies that a break statement appears in a valid context.
breakStatement - the break statement to inspectResets label-tracking state before verifying a class code block.
code - the statement container to verify Verifies that a continue statement appears in a valid loop context.
continueStatement - the continue statement to inspect Verifies labels inside a do/while loop.
loop - the loop to inspect Verifies labels inside a for loop.
loop - the loop to inspect Verifies labels inside an if/else statement.
cond - the conditional statement to inspectRegisters any labels introduced by the current statement.
s - the statement being entered Verifies labels inside a switch statement.
switchStatement - the switch statement to inspect Verifies labels inside a while loop.
loop - the loop to inspectCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.