當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。