Example #1
0
 @Override
 public JCTree visitTypeRef(final lombok.ast.TypeRef node, final Void p) {
   JCExpression typeRef;
   final String typeName = node.getTypeName();
   if (TYPES.containsKey(typeName)) {
     typeRef = M(node).TypeIdent(TYPES.get(typeName));
     typeRef = setGeneratedBy(typeRef, source);
     if ("void".equals(typeName)) return typeRef;
   } else {
     typeRef = chainDots(node, node.getTypeName());
     typeRef = setGeneratedBy(typeRef, source);
     if (!node.getTypeArgs().isEmpty()) {
       typeRef = M(node).TypeApply(typeRef, build(node.getTypeArgs(), JCExpression.class));
       typeRef = setGeneratedBy(typeRef, source);
     }
   }
   for (int i = 0; i < node.getDims(); i++) {
     typeRef = setGeneratedBy(M(node).TypeArray(typeRef), source);
   }
   return typeRef;
 }
Example #2
0
  protected TypeRef asTypeRef(MethodDescriptor.Type type) {
    if (type instanceof MethodDescriptor.Wildcard) {
      MethodDescriptor.Wildcard wildcard = (MethodDescriptor.Wildcard) type;
      if (wildcard.isExtends()) {
        return Wildcard(Wildcard.Bound.EXTENDS, Type(wildcard.parameters[0].type));
      } else if (wildcard.isSuper()) {
        return Wildcard(Wildcard.Bound.SUPER, Type(wildcard.parameters[0].type));
      } else {
        return Wildcard();
      }
    }

    TypeRef typeRef = Type(type.type);
    if (type.parameters.length > 0) {
      List<TypeRef> types = new ArrayList<>();
      for (int i = 0; i < type.parameters.length; i++) {
        types.add(asTypeRef(type.parameters[i]));
      }
      typeRef.withTypeArguments(types);
    }
    if (type.dimensions > 0) typeRef.withDimensions(type.dimensions);
    return typeRef;
  }