Package org.codehaus.groovy.classgen

# Class VerifierCodeVisitor

java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.classgen.VerifierCodeVisitor

All Implemented Interfaces:
  `GroovyCodeVisitor`

public class VerifierCodeVisitor extends CodeVisitorSupport
Performs various checks on code inside methods and constructors including checking for valid field, variables names etc. that would otherwise lead to invalid code.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `VerifierCodeVisitor(ClassNode classNode)`
  Creates a new verifier code visitor for the given class.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `assertValidIdentifier(String name, String message, ASTNode node)`
  Verifies that the supplied name is a valid Java identifier.
  `void`
  `visitConstructorCallExpression(ConstructorCallExpression call)`
  Visits a `ConstructorCallExpression`, traversing its argument list.
  `void`
  `visitFieldExpression(FieldExpression expression)`
  Visits a `FieldExpression`.
  `void`
  `visitForLoop(ForStatement statement)`
  Visits a `ForStatement`, traversing the collection expression and loop body.
  `void`
  `visitListExpression(ListExpression expression)`
  Visits a `ListExpression`, traversing all contained expressions.
  `void`
  `visitVariableExpression(VariableExpression expression)`
  Visits a `VariableExpression`.

  ### Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport

  `afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitArrayExpression, visitAssertStatement, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBlockStatement, visitBooleanExpression, visitBreakStatement, visitBytecodeExpression, visitCaseStatement, visitCastExpression, visitCatchStatement, visitClassExpression, visitClosureExpression, visitClosureListExpression, visitConstantExpression, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitEmptyStatement, visitExpressionStatement, visitGStringExpression, visitIfElse, visitLambdaExpression, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitSwitch, visitSynchronizedStatement, visitTernaryExpression, visitThrowStatement, visitTryCatchFinally, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitWhileLoop`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.codehaus.groovy.ast.GroovyCodeVisitor

  `visit, visit, visitEmptyExpression, visitListOfExpressions`

- ## Constructor Details

  - ### VerifierCodeVisitor

    public VerifierCodeVisitor(ClassNode classNode)
    Creates a new verifier code visitor for the given class.
    Parameters:
      `classNode` - the class node being verified

- ## Method Details

  - ### visitForLoop

    public void visitForLoop(ForStatement statement)
    Visits a `ForStatement`, traversing the collection expression and loop body.
    Specified by:
      `visitForLoop` in interface `GroovyCodeVisitor`
    Overrides:
      `visitForLoop` in class `CodeVisitorSupport`
    Parameters:
      `statement` - the for loop statement

  - ### visitFieldExpression

    public void visitFieldExpression(FieldExpression expression)
    Visits a `FieldExpression`. No traversal is performed as field expressions contain no child expressions.
    Specified by:
      `visitFieldExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitFieldExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the field expression

  - ### visitVariableExpression

    public void visitVariableExpression(VariableExpression expression)
    Visits a `VariableExpression`. No traversal is performed as variable expressions contain no child expressions.
    Specified by:
      `visitVariableExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitVariableExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the variable expression

  - ### visitListExpression

    public void visitListExpression(ListExpression expression)
    Visits a `ListExpression`, traversing all contained expressions.
    Specified by:
      `visitListExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitListExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the list expression

  - ### visitConstructorCallExpression

    public void visitConstructorCallExpression(ConstructorCallExpression call)
    Visits a `ConstructorCallExpression`, traversing its argument list.
    Specified by:
      `visitConstructorCallExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitConstructorCallExpression` in class `CodeVisitorSupport`
    Parameters:
      `call` - the constructor call expression

  - ### assertValidIdentifier

    public static void assertValidIdentifier(String name, String message, ASTNode node)
    Verifies that the supplied name is a valid Java identifier.
    Parameters:
      `name` - the identifier text to validate
      `message` - the error context to include in failures
      `node` - the node to associate with any parse error