Package: org.codehaus.groovy.ast

## [Java] Class MethodInvocationTrap

- org.codehaus.groovy.ast.MethodInvocationTrap

- Authors:
    Hamlet D'Arcy
    Sergei Egorov

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected ReaderSource` | `source` |
    `protected org.codehaus.groovy.control.SourceUnit` | `sourceUnit` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `MethodInvocationTrap (ReaderSource source, org.codehaus.groovy.control.SourceUnit sourceUnit)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and 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 boolean` | `handleTargetMethodCallExpression(MethodCallExpression call)`
    `` | `protected boolean` | `isBuildInvocation(MethodCallExpression call)`
    `` | `void` | `visitMethodCallExpression(MethodCallExpression call)` Attempts to find AstBuilder 'from code' invocations.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class CodeVisitorSupport` | `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, visitListExpression, visitListOfExpressions, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitSwitch, visitSynchronizedStatement, visitTernaryExpression, visitThrowStatement, visitTryCatchFinally, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, visitWhileLoop`
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Field Detail

    - #### protected final ReaderSource source

    - #### protected final org.codehaus.groovy.control.SourceUnit sourceUnit

  - ### Constructor Detail

    - #### public MethodInvocationTrap(ReaderSource source, org.codehaus.groovy.control.SourceUnit sourceUnit)

  - ### Method Detail

    - #### 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.

    - #### protected String convertClosureToSource(ClosureExpression expression)

      Converts a ClosureExpression into the String source.

      Parameters:
        `expression` - a closure
      Returns:
        the source the closure was created from

    - #### protected boolean handleTargetMethodCallExpression(MethodCallExpression call)

    - #### protected boolean isBuildInvocation(MethodCallExpression call)

    - #### public void visitMethodCallExpression(MethodCallExpression call)

      Attempts to find AstBuilder 'from code' invocations. When found, converts them into calls to the 'from string' approach.

      Parameters:
        `call` - the method call expression that may or may not be an AstBuilder 'from code' invocation.