io.vertx.codegen.type.TypeMirrorFactory Java Examples

The following examples show how to use io.vertx.codegen.type.TypeMirrorFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CodeTranslator.java    From vertx-codetrans with Apache License 2.0 6 votes vote down vote up
public CodeTranslator(ProcessingEnvironment processingEnv) {
  this.trees = Trees.instance(processingEnv);
  this.SystemType = (DeclaredType) processingEnv.getElementUtils().getTypeElement(System.class.getName()).asType();
  this.ThrowableType = (DeclaredType) processingEnv.getElementUtils().getTypeElement(Throwable.class.getName()).asType();
  Context context = ((JavacProcessingEnvironment)processingEnv).getContext();
  this.attr = Attr.instance(context);
  this.typeUtils = processingEnv.getTypeUtils();
  this.factory = new TypeMirrorFactory(processingEnv.getElementUtils(), processingEnv.getTypeUtils()) {
    @Override
    public TypeInfo create(TypeUse use, TypeMirror type) {
      if (type.getKind() == TypeKind.WILDCARD) {
        WildcardType wildcardType = (WildcardType) type;
        if (wildcardType.getExtendsBound() != null) {
          return super.create(wildcardType.getExtendsBound());
        } else if (wildcardType.getSuperBound() != null) {
          return super.create(use, wildcardType.getSuperBound());
        }
      }
      return super.create(use, type);
    }
  };
}
 
Example #2
Source File: WebApiProxyModelProvider.java    From vertx-web with Apache License 2.0 5 votes vote down vote up
@Override
public Model getModel(ProcessingEnvironment env, TypeMirrorFactory typeFactory, TypeElement elt) {
  if (elt.getAnnotation(WebApiServiceGen.class) != null) {
    WebApiProxyModel model = new WebApiProxyModel(env, typeFactory, elt);
    return model;
  } else {
    return null;
  }
}
 
Example #3
Source File: EnumModel.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
public EnumModel(ProcessingEnvironment env, TypeElement modelElt) {
  this.typeUtils = env.getTypeUtils();
  this.elementUtils = env.getElementUtils();
  this.typeMirrorFactory = new TypeMirrorFactory(elementUtils, typeUtils);
  this.docFactory = new Doc.Factory(env.getMessager(), elementUtils, typeUtils, typeMirrorFactory, modelElt);
  this.modelElt = modelElt;
  this.annotationValueInfoFactory = new AnnotationValueInfoFactory(typeMirrorFactory);
  this.deprecated = modelElt.getAnnotation(Deprecated.class) != null;
}
 
Example #4
Source File: Doc.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
public Factory(Messager messager, Elements elementUtils, Types typeUtils, TypeMirrorFactory typeFactory, TypeElement ownerElt) {
  this.messager = messager;
  this.elementUtils = elementUtils;
  this.typeUtils = typeUtils;
  this.typeFactory = typeFactory;
  this.ownerElt = ownerElt;
}
 
Example #5
Source File: Token.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
/**
 * Create a tag mapper that remaps tags with extra contexutal info like @link tags.
 *
 * @param elementUtils the element utils
 * @param typeUtils the type utils
 * @param ownerElt the type element in which this tag is declared
 * @return the mapper
 */
public static Function<Token, Token> tagMapper(
    Elements elementUtils, Types typeUtils, TypeElement ownerElt) {
  TypeMirrorFactory typeFactory = new TypeMirrorFactory(elementUtils, typeUtils);
  return token -> {
    if (token.isInlineTag()) {
      Tag tag = ((Token.InlineTag) token).getTag();
      if (tag.getName().equals("link")) {
        Matcher matcher = LINK_REFERENCE_PATTERN.matcher(tag.getValue());
        if (matcher.find()) {
          Element resolvedElt = Helper.resolveSignature(
              elementUtils,
              typeUtils,
              ownerElt,
              matcher.group(1));
          if (resolvedElt != null) {
            TypeElement resolvedTypeElt = Helper.getElementTypeOf(resolvedElt);
            if (resolvedTypeElt != null) {
              DeclaredType resolvedType = (DeclaredType) resolvedTypeElt.asType();
              Tag.Link tagLink = new Tag.Link(
                  tag.getValue(),
                  resolvedElt,
                  typeFactory.create(resolvedType),
                  tag.getValue().substring(matcher.end()));
              token = new Token.InlineTag(token.getValue(), tagLink);
            }
          }
        }
      }
    }
    return token;
  };
}
 
Example #6
Source File: ProxyModelProvider.java    From vertx-service-proxy with Apache License 2.0 5 votes vote down vote up
@Override
public Model getModel(ProcessingEnvironment env, TypeMirrorFactory typeFactory, TypeElement elt) {
  if (elt.getAnnotation(ProxyGen.class) != null) {
    ProxyModel model = new ProxyModel(env, typeFactory, elt);
    return model;
  } else {
    return null;
  }
}
 
Example #7
Source File: WebApiProxyModel.java    From vertx-web with Apache License 2.0 4 votes vote down vote up
public WebApiProxyModel(ProcessingEnvironment env, TypeMirrorFactory typeFactory,TypeElement modelElt) {
  super(env, typeFactory, modelElt);
}
 
Example #8
Source File: CodeGen.java    From vertx-codegen with Apache License 2.0 4 votes vote down vote up
public CodeGen(ProcessingEnvironment env) {
  this.env = env;
  this.elementUtils = env.getElementUtils();
  this.typeUtils = env.getTypeUtils();
  this.tmf = new TypeMirrorFactory(elementUtils, typeUtils);
}
 
Example #9
Source File: ModelProvider.java    From vertx-codegen with Apache License 2.0 votes vote down vote up
Model getModel(ProcessingEnvironment env, TypeMirrorFactory typeFactory, TypeElement elt);