public static boolean isMethodCallOnObject(Expression expression, String methodObjectPattern) {
        if (expression instanceof MethodCallExpression) {
            Expression objectExpression = ((MethodCallExpression) expression).getObjectExpression();
            if (objectExpression instanceof VariableExpression) {
                String name = ((VariableExpression) objectExpression).getName();
                if (name != null && name.matches(methodObjectPattern)) {
                    return true;
                }
            }
            if (objectExpression instanceof PropertyExpression && objectExpression.getText() != null && objectExpression.getText().matches(methodObjectPattern)) {
                return true;
            }
            if (objectExpression instanceof MethodCallExpression && isMethodNamed((MethodCallExpression) objectExpression, methodObjectPattern)) {
                return true;
            }
        }
        return false;
    }
public static boolean isMethodCallOnObject ( Expression expression , String methodObjectPattern ) { if ( expression instanceof MethodCallExpression ) { Expression objectExpression = ( ( MethodCallExpression ) expression ) . getObjectExpression ( ) ; if ( objectExpression instanceof VariableExpression ) { String name = ( ( VariableExpression ) objectExpression ) . getName ( ) ; if ( name != null && name . matches ( methodObjectPattern ) ) { return true ; } } if ( objectExpression instanceof PropertyExpression && objectExpression . getText ( ) != null && objectExpression . getText ( ) . matches ( methodObjectPattern ) ) { return true ; } if ( objectExpression instanceof MethodCallExpression && isMethodNamed ( ( MethodCallExpression ) objectExpression , methodObjectPattern ) ) { return true ; } } return false ; }
Tells you if the expression is a method call on a particular object (which is represented as a String).
For instance, you may ask isMethodCallOnObject(e, 'this') to find a this reference.
@param expression - the expression
@param methodObjectPattern - the name of the method object (receiver) such as 'this'
@return
as described