当前位置: 首页>>代码示例>>Java>>正文


Java TypeMirrorFactory类代码示例

本文整理汇总了Java中io.vertx.codegen.type.TypeMirrorFactory的典型用法代码示例。如果您正苦于以下问题:Java TypeMirrorFactory类的具体用法?Java TypeMirrorFactory怎么用?Java TypeMirrorFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TypeMirrorFactory类属于io.vertx.codegen.type包,在下文中一共展示了TypeMirrorFactory类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: CodeTranslator

import io.vertx.codegen.type.TypeMirrorFactory; //导入依赖的package包/类
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);
    }
  };
}
 
开发者ID:vert-x3,项目名称:vertx-codetrans,代码行数:23,代码来源:CodeTranslator.java

示例2: process

import io.vertx.codegen.type.TypeMirrorFactory; //导入依赖的package包/类
boolean process() {
  if (!processed) {
    if (modelElt.getKind() != ElementKind.ENUM) {
      throw new GenException(modelElt, "@VertxGen can only be used with interfaces or enums" + modelElt.asType().toString());
    }
    doc = docFactory.createDoc(modelElt);
    type = (EnumTypeInfo) new TypeMirrorFactory(elementUtils, typeUtils).create(modelElt.asType());
    Helper.checkUnderModule(this, "@VertxGen");
    values = elementUtils.
        getAllMembers(modelElt).
        stream().
        filter(elt -> elt.getKind() == ElementKind.ENUM_CONSTANT).
        flatMap(Helper.cast(VariableElement.class)).
        map(elt -> new EnumValueInfo(elt.getSimpleName().toString(), docFactory.createDoc(elt))).
        collect(Collectors.toList());
    if (values.isEmpty()) {
      throw new GenException(modelElt, "No empty enums");
    }
    processed = true;
    return true;
  } else {
    return false;
  }
}
 
开发者ID:vert-x3,项目名称:vertx-codegen,代码行数:25,代码来源:EnumModel.java

示例3: Factory

import io.vertx.codegen.type.TypeMirrorFactory; //导入依赖的package包/类
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;
}
 
开发者ID:vert-x3,项目名称:vertx-codegen,代码行数:8,代码来源:Doc.java

示例4: tagMapper

import io.vertx.codegen.type.TypeMirrorFactory; //导入依赖的package包/类
/**
 * 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;
  };
}
 
开发者ID:vert-x3,项目名称:vertx-codegen,代码行数:41,代码来源:Token.java

示例5: init

import io.vertx.codegen.type.TypeMirrorFactory; //导入依赖的package包/类
@Override
public void init(ProcessingEnvironment processingEnv) {
  factory = new TypeMirrorFactory(processingEnv.getElementUtils(), processingEnv.getTypeUtils());
  translator = new CodeTranslator(processingEnv);
  env = processingEnv;
}
 
开发者ID:vert-x3,项目名称:vertx-lang-ceylon,代码行数:7,代码来源:CeylonDocGenerator.java

示例6: EnumModel

import io.vertx.codegen.type.TypeMirrorFactory; //导入依赖的package包/类
public EnumModel(Messager messager, Elements elementUtils, Types typeUtils, TypeElement modelElt) {
  this.docFactory = new Doc.Factory(messager, elementUtils, typeUtils, new TypeMirrorFactory(elementUtils, typeUtils), modelElt);
  this.typeUtils = typeUtils;
  this.elementUtils = elementUtils;
  this.modelElt = modelElt;
}
 
开发者ID:vert-x3,项目名称:vertx-codegen,代码行数:7,代码来源:EnumModel.java


注:本文中的io.vertx.codegen.type.TypeMirrorFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。