MethodInvocationTrap (Groovy 5.1.0)
Description: declaration: package: org.codehaus.groovy.ast, class: MethodInvocationTrap

Package org.codehaus.groovy.ast

# Class MethodInvocationTrap

java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.ast.MethodInvocationTrap

All Implemented Interfaces:
  `GroovyCodeVisitor`

public abstract class MethodInvocationTrap extends CodeVisitorSupport

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final ReaderSource`
  `source`
  `protected final SourceUnit`
  `sourceUnit`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MethodInvocationTrap(ReaderSource source, SourceUnit sourceUnit)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `addError(String msg, ASTNode expr)`
  Reports an error back to the source unit.
  `protected String`
  `convertClosureToSource(ClosureExpression expression)`
  Converts a ClosureExpression into the String source.
  `protected abstract boolean`
  `handleTargetMethodCallExpression(MethodCallExpression call)`
  `protected abstract boolean`
  `isBuildInvocation(MethodCallExpression call)`
  `void`
  `visitMethodCallExpression(MethodCallExpression call)`
  Attempts to find AstBuilder 'from code' invocations.

  ### 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, visitConstructorCallExpression, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitEmptyStatement, visitExpressionStatement, visitFieldExpression, visitForLoop, visitGStringExpression, visitIfElse, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitSwitch, visitSynchronizedStatement, visitTernaryExpression, visitThrowStatement, visitTryCatchFinally, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, 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`

- ## Field Details

  - ### source

    protected final ReaderSource source

  - ### sourceUnit

    protected final SourceUnit sourceUnit

- ## Constructor Details

  - ### MethodInvocationTrap

    public MethodInvocationTrap(ReaderSource source, SourceUnit sourceUnit)

- ## Method Details

  - ### visitMethodCallExpression

    public void visitMethodCallExpression(MethodCallExpression call)
    Attempts to find AstBuilder 'from code' invocations. When found, converts them into calls to the 'from string' approach.
    Specified by:
      `visitMethodCallExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitMethodCallExpression` in class `CodeVisitorSupport`
    Parameters:
      `call` - the method call expression that may or may not be an AstBuilder 'from code' invocation.

  - ### addError

    protected void addError(String msg, ASTNode expr)
    Reports an error back to the source unit.
    Parameters:
      `msg` - the error message
      `expr` - the expression that caused the error message.

  - ### convertClosureToSource

    protected String convertClosureToSource(ClosureExpression expression)
    Converts a ClosureExpression into the String source.
    Parameters:
      `expression` - a closure
    Returns:
      the source the closure was created from

  - ### handleTargetMethodCallExpression

    protected abstract boolean handleTargetMethodCallExpression(MethodCallExpression call)

  - ### isBuildInvocation

    protected abstract boolean isBuildInvocation(MethodCallExpression call)