public static JClassLiteral extractClassLiteral(TreeLogger logger, JMethodCall methodCall, int paramPosition, UnifyAstView ast) throws UnableToCompleteException { List<JExpression> args = methodCall.getArgs(); JExpression arg = args.get(paramPosition); JClassLiteral classLit = extractClassLiteral(logger, arg, ast, false); if (classLit == null) { logger.log(Type.ERROR, "The method " + methodCall.getTarget().toSource() + " only accepts class literals." + " You sent a " + arg.getClass() + " : " + arg.toSource()+" from method " + methodCall.toSource()+ " with argumetsn " + methodCall.getArgs()+ ";"); throw new UnableToCompleteException(); } return classLit; }
@Override public JExpression injectMagic(TreeLogger logger, JMethodCall methodCall, JMethod enclosingMethod, Context context, UnifyAstView ast) throws UnableToCompleteException { JExpression ctorProvider = super.injectMagic(logger, methodCall, enclosingMethod, context, ast); // call the newInstance method on the result of our ctorProvider JDeclaredType ctor = ast.searchForTypeBySource(Constructor.class.getName()); for (JMethod method : ctor.getMethods()) { if (method.getName().equals("newInstance")) { JMethodCall call = new JMethodCall(method.getSourceInfo(), ctorProvider, method); call.addArg(methodCall.getArgs().get(2)); return call; } } logger.log(Type.ERROR, "Unable to implement GwtReflect.construct from "+methodCall.toSource()); throw new UnableToCompleteException(); }
@Override public JExpression injectMagic(final TreeLogger logger, final JMethodCall methodCall, final JMethod enclosingMethod, final Context context, final UnifyAstView ast) throws UnableToCompleteException { final JExpression ctorProvider = super.injectMagic(logger, methodCall, enclosingMethod, context, ast); // Find the invoker method // call the newInstance method on the result of our ctorProvider final JDeclaredType ctor = ast.searchForTypeBySource(Constructor.class.getName()); for (final JMethod method : ctor.getMethods()) { if (method.getName().equals("newInstance")) { final JMethodCall call = new JMethodCall(methodCall.getSourceInfo().makeChild(), ctorProvider, method); call.addArg(methodCall.getArgs().get(2)); return call; } } logger.log(Type.ERROR, "Unable to implement GwtReflect.construct from "+methodCall.toSource()); throw new UnableToCompleteException(); }
@Override public JExpression injectMagic(TreeLogger logger, JMethodCall methodCall, JMethod enclosingMethod, Context context, UnifyAstView ast) throws UnableToCompleteException { JExpression methodProvider = super.injectMagic(logger, methodCall, enclosingMethod, context, ast); if (methodCall.getArgs().size() != 5) { logger.log(Type.ERROR, "Method call provided to replace GwtReflect.invoke(" + "Class<?> cls, String name, Class<?>[] paramTypes, Object inst, Object ... params" + ") supplied incorrect number of arguments; you supplied "+methodCall.getArgs().size() +" arguments: "+methodCall.getArgs()); throw new UnableToCompleteException(); } // call the invoke method on the result of our methodProvider JDeclaredType ctor = ast.searchForTypeBySource(Method.class.getName()); for (JMethod method : ctor.getMethods()) { if (method.getName().equals("invoke")) { JMethodCall call = new JMethodCall(method.getSourceInfo(), methodProvider, method); call.addArg(methodCall.getArgs().get(3)); call.addArg(methodCall.getArgs().get(4)); return call; } } logger.log(Type.ERROR, "Unable to implement GwtReflect.invoke from "+methodCall.toSource()); throw new UnableToCompleteException(); }
@Override public JExpression injectMagic(final TreeLogger logger, final JMethodCall methodCall, final JMethod enclosingMethod, final Context context, final UnifyAstView ast) throws UnableToCompleteException { final JExpression methodProvider = super.injectMagic(logger, methodCall, enclosingMethod, context, ast); if (isThrowStatement(methodProvider)) { return methodProvider; } if (methodCall.getArgs().size() != 5) { logger.log(Type.ERROR, "Method call provided to replace GwtReflect.invoke(" + "Class<?> cls, String name, Class<?>[] paramTypes, Object inst, Object ... params" + ") supplied incorrect number of arguments; you supplied "+methodCall.getArgs().size() +" arguments: "+methodCall.getArgs()); throw new UnableToCompleteException(); } // call the invoke method on the result of our methodProvider final JDeclaredType ctor = ast.searchForTypeBySource(Method.class.getName()); for (final JMethod method : ctor.getMethods()) { if (method.getName().equals("invoke")) { final JMethodCall call = new JMethodCall(method.getSourceInfo(), methodProvider, method); call.addArg(methodCall.getArgs().get(3)); call.addArg(methodCall.getArgs().get(4)); return call; } } logger.log(Type.ERROR, "Unable to implement GwtReflect.invoke from "+methodCall.toSource()); throw new UnableToCompleteException(); }
if (logger.isLoggable(logLevel())) { final TreeLogger branch = logger.branch(logLevel(), "Generated asynchronous magic singleton: "); for (final String str : call.toSource().split("\n")) { branch.log(logLevel(), str);
logger.log(logLevel(), "Generating annotation provider for "+annotation+" @ "+callSite.toSource());