Example #1
0
 @Override
 public JCTree visitTypeParam(final lombok.ast.TypeParam node, final Void p) {
   JCTypeParameter typeParam =
       setGeneratedBy(
           M(node)
               .TypeParameter(name(node.getName()), build(node.getBounds(), JCExpression.class)),
           source);
   return typeParam;
 }
Example #2
0
  @Override
  public JCTree visitWrappedMethodDecl(final lombok.ast.WrappedMethodDecl node, final Void p) {
    MethodSymbol methodSymbol = (MethodSymbol) node.getWrappedObject();
    Type mtype = methodSymbol.type;

    if (node.getReturnType() == null) {
      node.withReturnType(Type(fixLeadingDot(node, M(node).Type(mtype.getReturnType()))));
    }
    if (node.getThrownExceptions().isEmpty())
      for (JCExpression expr : M(node).Types(mtype.getThrownTypes())) {
        node.withThrownException(Type(fixLeadingDot(node, expr)));
      }
    if (node.getArguments().isEmpty())
      for (JCVariableDecl param : M(node).Params(mtype.getParameterTypes(), methodSymbol)) {
        node.withArgument(Arg(Type(fixLeadingDot(node, param.vartype)), As.string(param.name)));
      }
    if (node.getTypeParameters().isEmpty())
      for (JCTypeParameter typaram : M(node).TypeParams(mtype.getTypeArguments())) {
        final lombok.ast.TypeParam typeParam = TypeParam(As.string(typaram.name));
        for (JCExpression expr : typaram.bounds) {
          typeParam.withBound(Type(fixLeadingDot(node, expr)));
        }
        node.withTypeParameter(typeParam);
      }

    final JCModifiers mods =
        M(node)
            .Modifiers(
                methodSymbol.flags() & (~Flags.ABSTRACT),
                build(node.getAnnotations(), JCAnnotation.class));
    final JCExpression restype = build(node.getReturnType());
    final Name name = methodSymbol.name;
    final List<JCExpression> thrown = build(node.getThrownExceptions(), JCExpression.class);
    final List<JCTypeParameter> typarams = build(node.getTypeParameters(), JCTypeParameter.class);
    final List<JCVariableDecl> params = build(node.getArguments(), JCVariableDecl.class);
    JCBlock body = null;
    if (!node.noBody()) {
      body = M(node).Block(0, build(node.getStatements(), JCStatement.class));
    }
    final JCMethodDecl method =
        M(node).MethodDef(mods, name, restype, typarams, params, thrown, body, null);
    return method;
  }