Add a call to emit an event at the end of the function

@param originalMethod Method we are emitting an event for
@param proxyMethodBuilder Method we are building
@param methodCallParameters Chained parameters name of the method
977508
private void addEmitEventCall(ExecutableElement originalMethod,
      MethodSpec.Builder proxyMethodBuilder, String methodCallParameters) {
    String methodName = "$emit";
    if (methodCallParameters != null && !"".equals(methodCallParameters)) {
      proxyMethodBuilder.addStatement("vue().$L($S, $L)",
          methodName,
          methodToEventName(originalMethod),
          methodCallParameters);
    } else {
      proxyMethodBuilder.addStatement("vue().$L($S)",
          methodName,
          methodToEventName(originalMethod));
    }
  }
903664
@Override
    public void emitConstructorMethod(Sink sink, String indent, Constructor constructor) {
    	logger.finest("Generating constructor method for " + constructor.name);
    	final List<JavaComment> javaDoc = commentProcessor.leftAlign(commentProcessor.javaDocOnly(constructor.comments));
    	for (Arg arg : constructor.args) {
    	    final List<JavaComment> paramDoc = commentProcessor.paramDoc(arg.name, javaDoc);
    	    sink.write(ASTPrinter.printComments(indent, paramDoc));
            sink.write(indent + "public ");
            sink.write(ASTPrinter.printArgModifiers(arg.modifiers));
            sink.write(ASTPrinter.print(arg.type) + " " + arg.name + ";\n");
        }
    	sink.write("\n");
        sink.write(ASTPrinter.printComments(indent, commentProcessor.leftAlign(commentProcessor.stripTags(CONSTRUCTOR_METHOD_STRIP, commentProcessor.javaDocOnly(constructor.comments)))));    	
        sink.write(indent + "public " + constructor.name + "("); 
        constructorArgs(sink, constructor, true);        
        sink.write(") {");
        for (Arg arg : constructor.args) {
            sink.write("\n" + indent + "   this." + arg.name + " = " + arg.name + ";");
        }
        sink.write("\n" + indent + "}");
    }
721650
public final String callMethod(String method) {
    parent.assertConnected();
    return debugger.callFunctionOnObject(method, objectId);
  }
918865
@Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
    {
        if (constructed)
        {

            String methodName = method.getName();
            int params = args.length;

            if (params == 0)
            {
                if (isUninitialized() && method.equals(getIdentifierMethod))
                {
                    return getIdentifier();
                }

                else if ("getKunderaLazyInitializer".equals(methodName))
                {
                    return this;
                }
            }

            Object target = getImplementation();

            String[] strArr = entityName.split("#");
            String fieldName = strArr[1];

            if (owner != null)
            {
                EntityMetadata m = KunderaMetadataManager.getEntityMetadata(persistenceDelegator.getKunderaMetadata(),
                        owner.getClass());
                Relation r = m.getRelation(fieldName);
                if (r != null)
                {
                    PropertyAccessorHelper.set(owner, r.getProperty(), target);
                }
                if (r.getBiDirectionalField() != null && method.getReturnType().equals(m.getEntityClazz()))
                {
                    PropertyAccessorHelper.set(target, r.getBiDirectionalField(), owner);
                }

            }

            try
            {
                final Object returnValue;
                if (method.isAccessible())
                {
                    if (!method.getDeclaringClass().isInstance(target))
                    {
                        throw new ClassCastException(target.getClass().getName());
                    }
                    returnValue = method.invoke(target, args);
                }
                else
                {
                    if (!method.isAccessible())
                    {
                        method.setAccessible(true);
                    }
                    returnValue = method.invoke(target, args);
                }
                return ((returnValue == target) ? proxy : returnValue);
            }
            catch (InvocationTargetException ite)
            {
                throw new LazyInitializationException(ite);
            }
        }
        else
        {
            // while constructor is running
            throw new LazyInitializationException("unexpected case hit, method=" + method.getName());
        }

    }
380820
@Override
    protected void createForwardingMethodBody(ClassMethod classMethod, final MethodInformation methodInfo, ClassMethod staticConstructor) {
        final Method method = methodInfo.getMethod();
        // we can only use bytecode based invocation for some methods
        // at the moment we restrict it solely to public methods with public
        // return and parameter types
        boolean bytecodeInvocationAllowed = Modifier.isPublic(method.getModifiers()) && Modifier.isPublic(method.getReturnType().getModifiers());
        for (Class<?> paramType : method.getParameterTypes()) {
            if (!Modifier.isPublic(paramType.getModifiers())) {
                bytecodeInvocationAllowed = false;
                break;
            }
        }
        if (!bytecodeInvocationAllowed) {
            createInterceptorBody(classMethod, methodInfo, staticConstructor);
            return;
        }

        // create a new interceptor invocation context whenever we invoke a method on a client proxy
        // we use a try-catch block in order to make sure that endInterceptorContext() is invoked regardless whether
        // the method has succeeded or not

        new RunWithinInterceptionDecorationContextGenerator(classMethod, this) {

            @Override
            void doWork(CodeAttribute b, ClassMethod classMethod) {
                loadBeanInstance(classMethod.getClassFile(), methodInfo, b);
                //now we should have the target bean instance on top of the stack
                // we need to dup it so we still have it to compare to the return value
                b.dup();

                //lets create the method invocation
                String methodDescriptor = methodInfo.getDescriptor();
                b.loadMethodParameters();
                if (method.getDeclaringClass().isInterface()) {
                    b.invokeinterface(methodInfo.getDeclaringClass(), methodInfo.getName(), methodDescriptor);
                } else {
                    b.invokevirtual(methodInfo.getDeclaringClass(), methodInfo.getName(), methodDescriptor);
                }
            }

            @Override
            void doReturn(CodeAttribute b, ClassMethod classMethod) {
                // assumes doWork() result is on top of the stack
                // if this method returns a primitive we just return
                if (method.getReturnType().isPrimitive()) {
                    b.returnInstruction();
                } else {
                    // otherwise we have to check that the proxy is not returning 'this;
                    // now we need to check if the proxy has return 'this' and if so return
                    // an
                    // instance of the proxy.
                    // currently we have result, beanInstance on the stack.
                    b.dupX1();
                    // now we have result, beanInstance, result
                    // we need to compare result and beanInstance

                    // first we need to build up the inner conditional that just returns
                    // the
                    // result
                    final BranchEnd returnInstruction = b.ifAcmpeq();
                    b.returnInstruction();
                    b.branchEnd(returnInstruction);

                    // now add the case where the proxy returns 'this';
                    b.aload(0);
                    b.checkcast(methodInfo.getMethod().getReturnType().getName());
                    b.returnInstruction();
                }
            }
        }.runStartIfNotEmpty();
    }
1008463
private void addProxyDeathMethod(TypeSpec.Builder classBuilder, String deathMethod, String doc) {
        MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(deathMethod)
                .addModifiers(Modifier.PUBLIC)
                .returns(TypeName.VOID)
                .addParameter(ClassName.get("android.os", "IBinder.DeathRecipient"), "deathRecipient")
                .beginControlFlow("try")
                .addStatement("mRemote." + deathMethod + "(deathRecipient, 0)")
                .endControlFlow()
                .beginControlFlow("catch ($T ignored)", Exception.class)
                .endControlFlow()
                .addJavadoc(doc);
        classBuilder.addMethod(methodBuilder.build());
    }
1242724
public static MethodInvokeProxy proxyByName(Object target,String methodName,Object ...args)
	{
		Method m=findMethodByName(target, methodName);
		if(m!=null)
		{
			return new MethodInvokeProxy(target, m, args);
		}
		return null;
	}
416155
public static void injectMethod(JavacNode typeNode, JCMethodDecl method, List<Type> paramTypes, Type returnType) {
		JCClassDecl type = (JCClassDecl) typeNode.get();
		
		if (method.getName().contentEquals("<init>")) {
			//Scan for default constructor, and remove it.
			int idx = 0;
			for (JCTree def : type.defs) {
				if (def instanceof JCMethodDecl) {
					if ((((JCMethodDecl) def).mods.flags & Flags.GENERATEDCONSTR) != 0) {
						JavacNode tossMe = typeNode.getNodeFor(def);
						if (tossMe != null) tossMe.up().removeChild(tossMe);
						type.defs = addAllButOne(type.defs, idx);
						ClassSymbolMembersField.remove(type.sym, ((JCMethodDecl) def).sym);
						break;
					}
				}
				idx++;
			}
		}
		
		addSuppressWarningsAll(method.mods, typeNode, method.pos, getGeneratedBy(method), typeNode.getContext());
		addGenerated(method.mods, typeNode, method.pos, getGeneratedBy(method), typeNode.getContext());
		type.defs = type.defs.append(method);
		
		fixMethodMirror(typeNode.getContext(), typeNode.getElement(), method.getModifiers().flags, method.getName(), paramTypes, returnType);
		
		typeNode.add(method, Kind.METHOD);
	}
511760
public void visitApply(JCMethodInvocation tree) {
        setTypeAnnotationPositions(tree.pos);
        // Generate code for method.
        Item m = genExpr(tree.meth, methodType);
        // Generate code for all arguments, where the expected types are
        // the parameters of the method's external type (that is, any implicit
        // outer instance of a super(...) call appears as first parameter).
        MethodSymbol msym = (MethodSymbol)TreeInfo.symbol(tree.meth);
        genArgs(tree.args,
                msym.externalType(types).getParameterTypes());
        if (!msym.isDynamic()) {
            code.statBegin(tree.pos);
        }
        result = m.invoke();
    }
405970
@Override
  public Object invoke(Object[] argv) throws Throwable {
    if (handle == null) {
      throw new IllegalStateException(
          "Default method handler invoked before proxy has been bound.");
    }
    return handle.invokeWithArguments(argv);
  }
927882
public void invokeMethod(String method, Object[] methodParams, IRemotingCallback callback) {
        try {
            RemotingWorker worker = new RemotingWorker(this, method, methodParams, callback);
            executor.execute(worker);
        } catch (Exception err) {
            log.warn("Exception invoking method: {}", method, err);
        }
    }
89168
public void setInvocationHandler(Object proxy, InvocationHandler handler) {
        Field field = getInvocationHandlerField();
        try {
            field.set(proxy, handler);
        } catch (IllegalArgumentException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }
1331961
public MethodDoc wrap(MethodDoc source) {
		if (source == null || source instanceof Proxy<?> || !(source instanceof MethodDocImpl)) {
			return source;
		}
		return new MethodDocWrapper((MethodDocImpl) source);
	}
1243791
@SneakyThrows
    public final void recordMethodInvocation(final Class<?> targetClass, final String methodName, final Class<?>[] argumentTypes, final Object[] arguments) {
        jdbcMethodInvocations.add(new JdbcMethodInvocation(targetClass.getMethod(methodName, argumentTypes), arguments));
    }
173779
private void callMethod(final String methodName, final Event event) {
        final Class<?> ctrlClass = this.callbackObject.getClass();

        try {
            final Method method = ctrlClass.getDeclaredMethod(methodName, event.getClass());

            ClassUtility.callMethod(method, this.callbackObject, event);

        } catch (NoSuchMethodException | SecurityException | IllegalArgumentException | CoreException e) {
            LOGGER.log(EVENT_HANDLING_IMPOSSIBLE, e);
        }

    }
150002
@Override
    public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
        if (SplitlogLoggerFactory.isLoggingEnabled()) {
            SplitlogLoggerFactory.increaseMessageCounter();
            return method.invoke(this.proxied, args);
        } else {
            // logging is not enabled, don't proxy the call
            return null;
        }
    }
878193
@Override
	public Object intercept(Object object, Method method, Object[] args,
			MethodProxy methodProxy) throws Throwable {
		Method delegateMethod = delegateClass.getMethod(method.getName(),
				method.getParameterTypes());
		if ("registerBeanDefinition".equals(method.getName())) {
			if (beanDefinitionMap.containsKey(args[0])) {
				List<BeanDefinition> definitions = beanDefinitionMap
						.get(args[0]);
				definitions.add((BeanDefinition) args[1]);
			} else {
				List<BeanDefinition> beanDefinitions = new ArrayList<BeanDefinition>();
				beanDefinitions.add((BeanDefinition) args[1]);
				beanDefinitionMap.put((String) args[0], beanDefinitions);
			}
		}
		return delegateMethod.invoke(delegate, args);
	}