Example usage for javax.annotation.processing ProcessingEnvironment getElementUtils

List of usage examples for javax.annotation.processing ProcessingEnvironment getElementUtils

Introduction

In this page you can find the example usage for javax.annotation.processing ProcessingEnvironment getElementUtils.

Prototype

Elements getElementUtils();

Source Link

Document

Returns an implementation of some utility methods for operating on elements

Usage

From source file:Main.java

/**
 * @param processingEnv//from   w  ww  . ja v  a2 s.c  o  m
 * @param element
 * @return
 */
public static String getPackageName(ProcessingEnvironment processingEnv, Element element) {
    return processingEnv.getElementUtils().getPackageOf(element).getQualifiedName().toString();
}

From source file:cop.raml.utils.javadoc.JavaDocUtils.java

public static String getDocComment(Element element, ProcessingEnvironment processingEnv) {
    String str = element != null ? processingEnv.getElementUtils().getDocComment(element) : null;
    return StringUtils.isNotBlank(str) ? str.trim() : null;
}

From source file:Main.java

public static boolean checkIfIsParcelable(ProcessingEnvironment processingEnvironment, String type) {
    TypeElement parcelableElement = processingEnvironment.getElementUtils()
            .getTypeElement("android.os.Parcelable");
    TypeElement elementType;//w  ww.  j  a  v a  2s  . c  om
    if (type.contains("<") && type.contains(">")) {
        elementType = processingEnvironment.getElementUtils()
                .getTypeElement(type.substring(type.indexOf("<") + 1, type.indexOf(">")));
    } else {
        elementType = processingEnvironment.getElementUtils()
                .getTypeElement(type.replace("[]", "").replace(">", ""));
    }
    if (elementType != null) {
        for (TypeMirror typeMirror : elementType.getInterfaces()) {
            if (typeMirror.toString().equals(parcelableElement.toString())) {
                return true;
            }
        }
    }
    return false;
}

From source file:org.mule.module.extension.internal.capability.xml.schema.AnnotationProcessorUtils.java

private static String extractJavadoc(ProcessingEnvironment processingEnv, Element element) {
    String comment = processingEnv.getElementUtils().getDocComment(element);

    if (StringUtils.isBlank(comment)) {
        return StringUtils.EMPTY;
    }/*ww w.  j  ava2 s  . c o  m*/

    return comment.trim();
}

From source file:Main.java

public static boolean checkIfIsSerializable(ProcessingEnvironment processingEnvironment, String type) {
    if (type.equals("java.lang.String") || type.equals("java.lang.Boolean")
            || type.equals("java.lang.Character")) {
        //it is serializable but we handle it different way
        return false;
    }//  w ww.j a v  a2s.  com

    TypeElement serializableElement = processingEnvironment.getElementUtils()
            .getTypeElement("java.io.Serializable");
    TypeElement elementType;

    elementType = processingEnvironment.getElementUtils().getTypeElement(type);

    if (elementType != null) {
        for (TypeMirror typeMirror : elementType.getInterfaces()) {
            if (typeMirror.toString().equals(serializableElement.toString())) {
                return true;
            }
        }
    }
    return false;
}

From source file:org.mule.module.extension.internal.capability.xml.schema.AnnotationProcessorUtils.java

/**
 * Returns the {@link Class} object that is associated to the {@code typeElement}
 *
 * @param typeElement           a {@link TypeElement} which represents a {@link Class}
 * @param processingEnvironment the current {@link ProcessingEnvironment}
 * @param <T>                   the generic type of the returned {@link Class}
 * @return the {@link Class} represented by {@code typeElement}
 *//*  w ww . j  a v  a 2s. com*/
public static <T> Class<T> classFor(TypeElement typeElement, ProcessingEnvironment processingEnvironment) {
    try {
        return ClassUtils.loadClass(
                processingEnvironment.getElementUtils().getBinaryName(typeElement).toString(),
                typeElement.getClass());
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.github.pellaton.jazoon2012.JazoonProcessor.java

/**
 * @see AbstractProcessor#init(ProcessingEnvironment)
 *///  w  w  w.  j a va2s . co m
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    this.elementUtils = processingEnv.getElementUtils();
    this.messager = processingEnv.getMessager();

    this.configurationTypeElement = this.elementUtils
            .getTypeElement("org.springframework.context.annotation.Configuration");
}

From source file:blue.lapis.pore.ap.event.EventVerifierProcessor.java

@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);

    this.bukkitEventType = checkNotNull(processingEnv.getElementUtils().getTypeElement(BUKKIT_EVENT_CLASS),
            "Bukkit event class").asType();
    this.spongeEventType = checkNotNull(processingEnv.getElementUtils().getTypeElement(SPONGE_EVENT_CLASS),
            "Sponge event class").asType();
}

From source file:uniol.apt.compiler.AbstractServiceProcessor.java

@Override
public synchronized void init(ProcessingEnvironment procEnv) {
    super.init(procEnv);
    this.elements = procEnv.getElementUtils();
    this.types = procEnv.getTypeUtils();
    this.filer = processingEnv.getFiler();
    this.messager = processingEnv.getMessager();
    this.finished = false;
}

From source file:info.archinnov.achilles.internals.apt.processors.meta.AchillesProcessor.java

@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);

    aptUtils = new AptUtils(processingEnv.getElementUtils(), processingEnv.getTypeUtils(),
            processingEnv.getMessager(), processingEnv.getFiler());
    entityParser = new EntityParser(aptUtils);
}