Java Code Examples for javax.annotation.processing.ProcessingEnvironment.getTypeUtils()

The following are Jave code examples for showing how to use getTypeUtils() of the javax.annotation.processing.ProcessingEnvironment class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: GitHub   File: TypeMirrors.java   Source Code and License Vote up 6 votes
TypeMirrors(ProcessingEnvironment env) {
    final Types typeUtils = env.getTypeUtils();
    final Elements elementUtils = env.getElementUtils();

    STRING_MIRROR = elementUtils.getTypeElement("java.lang.String").asType();
    BINARY_MIRROR = typeUtils.getArrayType(typeUtils.getPrimitiveType(TypeKind.BYTE));
    BOOLEAN_MIRROR = elementUtils.getTypeElement(Boolean.class.getName()).asType();
    LONG_MIRROR = elementUtils.getTypeElement(Long.class.getName()).asType();
    INTEGER_MIRROR = elementUtils.getTypeElement(Integer.class.getName()).asType();
    SHORT_MIRROR = elementUtils.getTypeElement(Short.class.getName()).asType();
    BYTE_MIRROR = elementUtils.getTypeElement(Byte.class.getName()).asType();
    DOUBLE_MIRROR = elementUtils.getTypeElement(Double.class.getName()).asType();
    FLOAT_MIRROR = elementUtils.getTypeElement(Float.class.getName()).asType();
    DATE_MIRROR = elementUtils.getTypeElement(Date.class.getName()).asType();

    PRIMITIVE_LONG_MIRROR = typeUtils.getPrimitiveType(TypeKind.LONG);
    PRIMITIVE_INT_MIRROR = typeUtils.getPrimitiveType(TypeKind.INT);
    PRIMITIVE_SHORT_MIRROR = typeUtils.getPrimitiveType(TypeKind.SHORT);
    PRIMITIVE_BYTE_MIRROR = typeUtils.getPrimitiveType(TypeKind.BYTE);
}
 
Example 2
Project: Spyglass   File: MainProcessor.java   Source Code and License Vote up 6 votes
@Override
public synchronized void init(final ProcessingEnvironment processingEnvironment) {
	super.init(processingEnvironment);

	elementUtil = processingEnvironment.getElementUtils();
	messager = processingEnvironment.getMessager();
	filer = processingEnvironment.getFiler();

	final CoreHelpers coreHelpers = new CoreHelpers(
			processingEnvironment.getElementUtils(),
			processingEnvironment.getTypeUtils());

	companionGenerator = new CompanionGenerator(coreHelpers);
	basicValidator = new BasicValidator();
	typeValidator = new TypeValidator(coreHelpers);

	createRequiredFiles();
}
 
Example 3
Project: convalida   File: ConvalidaProcessor.java   Source Code and License Vote up 5 votes
@Override
public synchronized void init(ProcessingEnvironment processingEnvironment) {
    super.init(processingEnvironment);

    this.elementUtils = processingEnvironment.getElementUtils();
    this.typeUtils = processingEnvironment.getTypeUtils();
    this.messager = processingEnvironment.getMessager();
    this.filer = processingEnvironment.getFiler();

    try {
        trees = Trees.instance(processingEnv);
    } catch (IllegalArgumentException ignored) { }
}
 
Example 4
Project: RIBs   File: RibProcessor.java   Source Code and License Vote up 5 votes
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
  super.init(processingEnv);
  elementUtils = processingEnv.getElementUtils();
  errorReporter = new ErrorReporter(processingEnv.getMessager());
  typesUtils = processingEnv.getTypeUtils();
  processorPipelines.addAll(getProcessorPipelines(this));
}
 
Example 5
Project: GitHub   File: MvpCompiler.java   Source Code and License Vote up 5 votes
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
	super.init(processingEnv);

	sMessager = processingEnv.getMessager();
	sTypeUtils = processingEnv.getTypeUtils();
	sElementUtils = processingEnv.getElementUtils();
	sOptions = processingEnv.getOptions();
}
 
Example 6
Project: GitHub   File: EasyMVPProcessor.java   Source Code and License Vote up 5 votes
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    elementUtils = processingEnv.getElementUtils();
    filer = processingEnv.getFiler();
    messager = processingEnv.getMessager();
    typeUtils = processingEnv.getTypeUtils();
}
 
Example 7
Project: domino   File: BaseProcessor.java   Source Code and License Vote up 5 votes
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    this.typeUtils=processingEnv.getTypeUtils();
    this.elementUtils=processingEnv.getElementUtils();
    this.filer=processingEnv.getFiler();
    this.messager=processingEnv.getMessager();
    this.elementFactory=new ElementFactory(elementUtils, typeUtils);
}
 
Example 8
Project: dataenum   File: ValueParser.java   Source Code and License Vote up 5 votes
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());
}
 
Example 9
Project: GitHub   File: JsonAnnotationProcessor.java   Source Code and License Vote up 5 votes
@Override
public synchronized void init(ProcessingEnvironment env) {
    super.init(env);

    mElementUtils = env.getElementUtils();
    mTypeUtils = env.getTypeUtils();
    mFiler = env.getFiler();
    mJsonObjectMap = new HashMap<>();
    mProcessors = Processor.allProcessors(processingEnv);
}
 
Example 10
Project: android-state   File: StateProcessor.java   Source Code and License Vote up 5 votes
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    mTypeUtils = processingEnv.getTypeUtils();
    mElementUtils = processingEnv.getElementUtils();
    mFiler = processingEnv.getFiler();
    mMessager = processingEnv.getMessager();
}
 
Example 11
Project: AptSpring   File: VerifiedSpringConfiguration.java   Source Code and License Vote up 5 votes
@Override
public synchronized void init(ProcessingEnvironment env) {
  super.init(env);
  Types typeUtils = env.getTypeUtils();
  Elements elementUtils = env.getElementUtils();
  Filer filer = env.getFiler();
  messager = env.getMessager();
  ErrorMessages errorMessages = ErrorMessages.builder()
      .cycleInDefinitionSources("Cycle in @Configuration class @Imports {0}")
      .cycleInObjectDefinitions("Cycle in spring bean dependencies {0}")
      .duplicateObjectDefinitions("Duplicate in spring beans {0}")
      .nonLiteralStaticMemberVariables("Non literal static member variables can break class instantiation and leak state")
      .knownDamagingClass("Known damaging class import (contains non-literal static member variables)")
      .missingBeanDefinitions("Missing bean definitions for spring beans {0},"
         + " create definitions or list them in @Verified'''s expected field")
      .missingRelevantAnnotations("Missing @Verified or @Configuration on classes {0}")
      .unmatchedTypes("Unmatched types {0}")
      .duplicatedMatchingDependencies("Duplicated matching dependencies {0}")
      .duplicatedMatchingDefinitions("Duplicated matching definitions {0}")
      .noMatchingDefinition("No matching definition {0}")
      .unusedExpected("Expected bean name is unnecessary {0}")
      .couldNotStore("Could not store incremental build file for {0}")
      .couldNotRead("Could not read incremental build file for {0}")
      .dependencyShaMismatch("Sha256 mismatch of dependency model of prior analyzed @Configuration model")
      .rootNodeImported("@Verfied(root=true) may not be @Imported by other @Verified @Configuration classes: {0}")
      .build();
  definitionAggregator = new AptParsingContext(errorMessages, filer, elementUtils, typeUtils);
}
 
Example 12
Project: autoproxy   File: AutoProxyProcessor.java   Source Code and License Vote up 5 votes
@Override
public synchronized void init(final ProcessingEnvironment pe) {
    super.init(pe);

    logger = pe.getMessager();
    typesUtil = pe.getTypeUtils();
    elementsUtil = pe.getElementUtils();
    filer = pe.getFiler();
}
 
Example 13
Project: Summer   File: ProtocolProcessor.java   Source Code and License Vote up 5 votes
@Override
public synchronized void init(ProcessingEnvironment env) {
    super.init(env);

    elementUtils = env.getElementUtils();
    typeUtils = env.getTypeUtils();
    filer = env.getFiler();
}
 
Example 14
Project: RxPay   File: EntityHandler.java   Source Code and License Vote up 5 votes
public EntityHandler(ProcessingEnvironment processingEnv) {
    this.elementUtils = processingEnv.getElementUtils();
    this.typeUtils = processingEnv.getTypeUtils();
    this.filer = processingEnv.getFiler();
    this.messager = processingEnv.getMessager();
    classEntityMap = new HashMap<>();
}
 
Example 15
Project: easyprefs   File: Processor.java   Source Code and License Vote up 5 votes
@Override
public synchronized void init(ProcessingEnvironment env) {
	super.init(env);

	ProcessorLog.init(env);

	mElementUtils = env.getElementUtils();
	mTypeUtils = env.getTypeUtils();
	mFiler = env.getFiler();
}
 
Example 16
Project: AbcPermission   File: GetPermissionsAutoProcessor.java   Source Code and License Vote up 5 votes
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    mFiler = processingEnv.getFiler();
    mElementUtils = processingEnv.getElementUtils();
    mMessager = processingEnv.getMessager();
    mLocale = processingEnv.getLocale();
    mOptions = processingEnv.getOptions();
    mTypeUtils = processingEnv.getTypeUtils();
}
 
Example 17
Project: auto-value-node   File: AutoValueNodeProcessor.java   Source Code and License Vote up 4 votes
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    typeUtils = processingEnv.getTypeUtils();
    elementUtils = processingEnv.getElementUtils();
}
 
Example 18
Project: openjdk-jdk10   File: Gen.java   Source Code and License Vote up 4 votes
void setProcessingEnvironment(ProcessingEnvironment pEnv) {
    processingEnvironment = pEnv;
    elems = pEnv.getElementUtils();
    types = pEnv.getTypeUtils();
    mangler = new Mangle(elems, types);
}
 
Example 19
Project: GitHub   File: ClassMetaData.java   Source Code and License Vote up 4 votes
public ClassMetaData(ProcessingEnvironment env, TypeMirrors typeMirrors, TypeElement clazz) {
    this.classType = clazz;
    this.className = clazz.getSimpleName().toString();
    typeUtils = env.getTypeUtils();
    elements = env.getElementUtils();


    validPrimaryKeyTypes = Arrays.asList(
            typeMirrors.STRING_MIRROR,
            typeMirrors.PRIMITIVE_LONG_MIRROR,
            typeMirrors.PRIMITIVE_INT_MIRROR,
            typeMirrors.PRIMITIVE_SHORT_MIRROR,
            typeMirrors.PRIMITIVE_BYTE_MIRROR
    );

    validListValueTypes = Arrays.asList(
            typeMirrors.STRING_MIRROR,
            typeMirrors.BINARY_MIRROR,
            typeMirrors.BOOLEAN_MIRROR,
            typeMirrors.LONG_MIRROR,
            typeMirrors.INTEGER_MIRROR,
            typeMirrors.SHORT_MIRROR,
            typeMirrors.BYTE_MIRROR,
            typeMirrors.DOUBLE_MIRROR,
            typeMirrors.FLOAT_MIRROR,
            typeMirrors.DATE_MIRROR
    );

    for (Element element : classType.getEnclosedElements()) {
        if (element instanceof ExecutableElement) {
            Name name = element.getSimpleName();
            if (name.contentEquals("toString")) {
                this.containsToString = true;
            } else if (name.contentEquals("equals")) {
                this.containsEquals = true;
            } else if (name.contentEquals("hashCode")) {
                this.containsHashCode = true;
            }
        }
    }

    ignoreKotlinNullability = Boolean.valueOf(
            env.getOptions().getOrDefault(OPTION_IGNORE_KOTLIN_NULLABILITY, "false"));
}
 
Example 20
Project: Alligator   File: ProcessingUtils.java   Source Code and License Vote up 4 votes
public ProcessingUtils(ProcessingEnvironment processingEnv) {
	typeUtils = processingEnv.getTypeUtils();
}