Example usage for com.google.gwt.dev.asm.commons Method Method

List of usage examples for com.google.gwt.dev.asm.commons Method Method

Introduction

In this page you can find the example usage for com.google.gwt.dev.asm.commons Method Method.

Prototype

public Method(final String name, final Type returnType, final Type[] argumentTypes) 

Source Link

Document

Creates a new Method .

Usage

From source file:com.google.web.bindery.requestfactory.server.RequestFactoryInterfaceValidator.java

License:Apache License

/**
 * Check that a given method RequestContext method declaration can be mapped
 * to the server's domain type./*from   w w  w.  ja v  a2s.  co  m*/
 */
private RFMethod checkClientMethodInDomain(ErrorContext logger, RFMethod method, Type domainServiceType,
        boolean requireStaticMethodsForRequestType) {
    logger = logger.setMethod(method);

    // Create a "translated" method declaration to search for
    // Request<BlahProxy> foo(int a, BarProxy bar) -> Blah foo(int a, Bar bar);
    Type returnType = getReturnType(logger, method);
    Method searchFor = createDomainMethod(logger,
            new Method(method.getName(), returnType, method.getArgumentTypes()));

    RFMethod found = findCompatibleServiceMethod(logger, domainServiceType, searchFor,
            !method.isValidationSkipped());

    if (found != null) {
        boolean isInstance = isAssignable(logger, instanceRequestIntf, method.getReturnType());
        if (isInstance && found.isDeclaredStatic()) {
            logger.poison("The method %s is declared to return %s, but the" + " service method is static",
                    method.getName(), InstanceRequest.class.getCanonicalName());
        } else if (requireStaticMethodsForRequestType && !isInstance && !found.isDeclaredStatic()) {
            logger.poison("The method %s is declared to return %s, but the" + " service method is not static",
                    method.getName(), Request.class.getCanonicalName());
        }
    }
    return found;
}

From source file:com.google.web.bindery.requestfactory.server.RequestFactoryInterfaceValidator.java

License:Apache License

/**
 * Convert a method declaration using client types (e.g. FooProxy) to domain
 * types (e.g. Foo)./*from   w  w w  .ja v  a 2s  .c  om*/
 */
private Method createDomainMethod(ErrorContext logger, Method clientMethod) {
    Type[] args = clientMethod.getArgumentTypes();
    for (int i = 0, j = args.length; i < j; i++) {
        args[i] = getDomainType(logger, args[i], true);
    }
    Type returnType = getDomainType(logger, clientMethod.getReturnType(), true);
    return new Method(clientMethod.getName(), returnType, args);
}

From source file:com.google.web.bindery.requestfactory.vm.impl.OperationKey.java

License:Apache License

private static String key(String requestContextBinaryName, String methodName, String descriptor) {
    Method m = new Method(methodName, Type.VOID_TYPE, Type.getArgumentTypes(descriptor));
    String raw = requestContextBinaryName + "::" + methodName + m.getDescriptor();
    return raw.length() >= HASH_LENGTH ? hash(raw) : raw;
}