javax.annotation.processing.ProcessingEnvironment#getTypeUtils ( )源码实例Demo

下面列出了javax.annotation.processing.ProcessingEnvironment#getTypeUtils ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Ollie   文件: OllieProcessor.java
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
	super.init(processingEnv);

	registry = new Registry(
			processingEnv.getMessager(),
			processingEnv.getTypeUtils(),
			processingEnv.getElementUtils(),
			processingEnv.getFiler());

	processingSteps = ImmutableSet.of(
			new MigrationStep(registry),
			new TypeAdapterStep(registry),
			new ColumnStep(registry),
			new ModelAdapterStep(registry),
			new AdapterHolderStep(registry));
}
 
@Override public boolean applicable(Context context) {
  ProcessingEnvironment env = context.processingEnvironment();
  Elements elements = env.getElementUtils();
  Types types = env.getTypeUtils();
  Messager messager = env.getMessager();
  TypeMirror parcelable = elements.getTypeElement(PARCELABLE_CLASS_NAME).asType();
  TypeElement autoValueTypeElement = context.autoValueClass();
  if (types.isAssignable(autoValueTypeElement.asType(), parcelable)) {
    PaperParcelAutoValueExtensionValidator extensionValidator =
        new PaperParcelAutoValueExtensionValidator(elements, types);
    ValidationReport<TypeElement> report = extensionValidator.validate(autoValueTypeElement);
    report.printMessagesTo(messager);
    return report.isClean();
  }
  return false;
}
 
@Override
public boolean applicable(Context context) {
    TypeElement typeElement = context.autoValueClass();
    boolean isApplicable = typeElement.getAnnotation(CombinedState.class) != null;
    if (isApplicable) {
        ProcessingEnvironment processingEnvironment = context.processingEnvironment();
        Env env = new Env(processingEnvironment.getTypeUtils(), processingEnvironment.getElementUtils(), processingEnvironment.getMessager(), processingEnvironment.getFiler());
        try {
            CombinedStateElement combinedStateElement = CombinedStateElement.parseAutoValueCombinedElement(typeElement, context.properties());
            CombinedStateProcessingStep.emmitCombinedReducer(env, combinedStateElement, ClassName.get(context.packageName(), "AutoValue_" + context.autoValueClass().getSimpleName()));
        } catch (ValidationException ve) {
            env.printError(ve.getElement(), ve.getMessage());
        } catch (Exception e) {
            env.printError(typeElement, "Internal processor error:\n" + e.getMessage());
            e.printStackTrace();
        }
    }

    return false;
}
 
源代码4 项目: vertx-codegen   文件: EnumModel.java
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;
}
 
源代码5 项目: Kratos   文件: KratosProcessor.java
@Override
public synchronized void init(ProcessingEnvironment env) {
    super.init(env);
    elementUtils = env.getElementUtils();
    typeUtils = env.getTypeUtils();
    filer = env.getFiler();
}
 
源代码6 项目: Akatsuki   文件: ProcessorContext.java
public ProcessorContext(ProcessingEnvironment environment) {
	this.environment = environment;
	this.types = environment.getTypeUtils();
	this.elements = environment.getElementUtils();
	this.utils = new ProcessorUtils(this.types, this.elements);

}
 
源代码7 项目: RxPay   文件: EntityHandler.java
public EntityHandler(ProcessingEnvironment processingEnv) {
    this.elementUtils = processingEnv.getElementUtils();
    this.typeUtils = processingEnv.getTypeUtils();
    this.filer = processingEnv.getFiler();
    this.messager = processingEnv.getMessager();
    classEntityMap = new HashMap<>();
}
 
源代码8 项目: jackdaw   文件: ProcessorUtils.java
public static TypeElement getWrappedType(final TypeMirror mirror) {
    final ProcessingEnvironment env = ProcessorContextHolder.getProcessingEnvironment();
    final Types typeUtils = env.getTypeUtils();

    final TypeKind kind = mirror.getKind();
    final boolean primitive = kind.isPrimitive();

    if (primitive) {
        return typeUtils.boxedClass((PrimitiveType) mirror);
    }
    return (TypeElement) typeUtils.asElement(mirror);
}
 
源代码9 项目: vertx-codegen   文件: DataObjectModel.java
public DataObjectModel(ProcessingEnvironment env, TypeMirrorFactory typeFactory, TypeElement modelElt) {
  this.elementUtils = env.getElementUtils();
  this.typeUtils = env.getTypeUtils();
  this.typeFactory = typeFactory;
  this.docFactory = new Doc.Factory(env.getMessager(), elementUtils, typeUtils, typeFactory, modelElt);
  this.modelElt = modelElt;
  this.annotationValueInfoFactory = new AnnotationValueInfoFactory(typeFactory);
  this.deprecated = modelElt.getAnnotation(Deprecated.class) != null;
}
 
源代码10 项目: YoDao   文件: YodaoProcessor.java
@Override
public synchronized void init(ProcessingEnvironment env) {
	super.init(env);

	elementUtils = env.getElementUtils();
	typeUtils = env.getTypeUtils();
	filer = env.getFiler();
}
 
源代码11 项目: toothpick   文件: ToothpickProcessor.java
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
  super.init(processingEnv);

  elementUtils = processingEnv.getElementUtils();
  typeUtils = processingEnv.getTypeUtils();
  filer = processingEnv.getFiler();
}
 
源代码12 项目: dataenum   文件: ValueParser.java
private static boolean isValueSpecMarker(
    TypeMirror returnType, ProcessingEnvironment processingEnvironment) {
  Types types = processingEnvironment.getTypeUtils();
  Elements elements = processingEnvironment.getElementUtils();

  return types.isSameType(
      returnType, elements.getTypeElement(dataenum_case.class.getCanonicalName()).asType());
}
 
源代码13 项目: firebase-android-sdk   文件: EncodableProcessor.java
@Override
public synchronized void init(ProcessingEnvironment processingEnvironment) {
  super.init(processingEnvironment);
  elements = processingEnvironment.getElementUtils();
  types = processingEnvironment.getTypeUtils();
  getterFactory = new GetterFactory(types, elements, processingEnvironment.getMessager());
}
 
@Override
public synchronized void init(ProcessingEnvironment env) {
    super.init(env);
    mContext = new ProcessorContext(env.getFiler(), env.getElementUtils(),
            env.getTypeUtils(), new ProcessorPrinter(env.getMessager()));
    mParser = new DataBindingParser(mContext);
}
 
@Override
public void init(final ProcessingEnvironment environment) {
    synchronized (this) {
        super.init(environment);

        typeUtils = environment.getTypeUtils();
        elementUtils = environment.getElementUtils();
        filer = environment.getFiler();
    }
}
 
源代码16 项目: mnemonic   文件: DurableEntityProcessor.java
/**
 * {@inheritDoc}
 */
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
  super.init(processingEnv);
  typeUtils = processingEnv.getTypeUtils();
  elementUtils = processingEnv.getElementUtils();
  filer = processingEnv.getFiler();
  messager = processingEnv.getMessager();
}
 
源代码17 项目: magic-starter   文件: TypeHelper.java
public TypeHelper(ProcessingEnvironment env) {
	this.env = env;
	this.types = env.getTypeUtils();
}
 
源代码18 项目: vault   文件: Processor.java
@Override public synchronized void init(ProcessingEnvironment processingEnv) {
  super.init(processingEnv);
  elementUtils = processingEnv.getElementUtils();
  typeUtils = processingEnv.getTypeUtils();
  filer = processingEnv.getFiler();
}
 
源代码19 项目: Alligator   文件: ProcessingUtils.java
public ProcessingUtils(ProcessingEnvironment processingEnv) {
	typeUtils = processingEnv.getTypeUtils();
}
 
源代码20 项目: dsl-json   文件: Analysis.java
public Analysis(
		ProcessingEnvironment processingEnv,
		AnnotationUsage annotationUsage,
		LogLevel logLevel,
		TypeSupport typeSupport,
		@Nullable Set<String> alternativeIgnore,
		@Nullable Map<String, List<AnnotationMapping<Boolean>>> alternativeNonNullable,
		@Nullable Map<String, String> alternativeAlias,
		@Nullable Map<String, List<AnnotationMapping<Boolean>>> alternativeMandatory,
		@Nullable Set<String> alternativeCreators,
		@Nullable Map<String, String> alternativeIndex,
		@Nullable UnknownTypes unknownTypes,
		boolean onlyBasicFeatures,
		boolean includeFields,
		boolean includeBeanMethods,
		boolean includeExactMethods) {
	this.annotationUsage = annotationUsage;
	this.logLevel = logLevel;
	this.elements = processingEnv.getElementUtils();
	this.types = processingEnv.getTypeUtils();
	this.messager = processingEnv.getMessager();
	this.compiledJsonElement = elements.getTypeElement(CompiledJson.class.getName());
	this.compiledJsonType = types.getDeclaredType(compiledJsonElement);
	this.attributeElement = elements.getTypeElement(JsonAttribute.class.getName());
	this.attributeType = types.getDeclaredType(attributeElement);
	this.converterElement = elements.getTypeElement(JsonConverter.class.getName());
	this.converterType = types.getDeclaredType(converterElement);
	this.typeSupport = typeSupport;
	this.alternativeIgnore = alternativeIgnore == null ? new HashSet<String>() : alternativeIgnore;
	this.alternativeNonNullable = alternativeNonNullable == null ? new HashMap<String, List<AnnotationMapping<Boolean>>>() : alternativeNonNullable;
	this.alternativeAlias = alternativeAlias == null ? new HashMap<String, String>() : alternativeAlias;
	this.alternativeMandatory = alternativeMandatory == null ? new HashMap<String, List<AnnotationMapping<Boolean>>>() : alternativeMandatory;
	this.alternativeCreators = alternativeCreators == null ? new HashSet<String>() : alternativeCreators;
	this.alternativeIndex = alternativeIndex == null ? new HashMap<String, String>() : alternativeIndex;
	this.unknownTypes = unknownTypes == null ? UnknownTypes.ERROR : unknownTypes;
	this.onlyBasicFeatures = onlyBasicFeatures;
	this.includeFields = includeFields;
	this.includeBeanMethods = includeBeanMethods;
	this.includeExactMethods = includeExactMethods;
	this.baseListType = types.erasure(elements.getTypeElement(List.class.getName()).asType());
	this.baseSetType = types.erasure(elements.getTypeElement(Set.class.getName()).asType());
	this.baseMapType = types.erasure(elements.getTypeElement(Map.class.getName()).asType());
}