Search in sources :

Example 1 with IRClass

use of org.androidannotations.rclass.IRClass in project androidannotations by androidannotations.

the class AndroidAnnotationProcessor method findRClasses.

private IRClass findRClasses(AndroidManifest androidManifest) throws RClassNotFoundException {
    try {
        timeStats.start("Find R Classes");
        IRClass rClass = new ProjectRClassFinder(androidAnnotationsEnv).find(androidManifest);
        IRClass androidRClass = new AndroidRClassFinder(processingEnv).find();
        return new CompoundRClass(rClass, androidRClass);
    } finally {
        timeStats.stop("Find R Classes");
    }
}
Also used : ProjectRClassFinder(org.androidannotations.internal.rclass.ProjectRClassFinder) AndroidRClassFinder(org.androidannotations.internal.rclass.AndroidRClassFinder) IRClass(org.androidannotations.rclass.IRClass) CompoundRClass(org.androidannotations.internal.rclass.CompoundRClass)

Example 2 with IRClass

use of org.androidannotations.rclass.IRClass in project androidannotations by androidannotations.

the class AndroidAnnotationProcessor method processThrowing.

private void processThrowing(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws Exception {
    if (nothingToDo(annotations, roundEnv)) {
        return;
    }
    AnnotationElementsHolder extractedModel = extractAnnotations(annotations, roundEnv);
    AnnotationElementsHolder validatingHolder = extractedModel.validatingHolder();
    androidAnnotationsEnv.setValidatedElements(validatingHolder);
    try {
        AndroidManifest androidManifest = extractAndroidManifest();
        LOGGER.info("AndroidManifest.xml found: {}", androidManifest);
        IRClass rClass = findRClasses(androidManifest);
        androidAnnotationsEnv.setAndroidEnvironment(rClass, androidManifest);
    } catch (Exception e) {
        return;
    }
    AnnotationElements validatedModel = validateAnnotations(extractedModel, validatingHolder);
    ModelProcessor.ProcessResult processResult = processAnnotations(validatedModel);
    generateSources(processResult);
}
Also used : AnnotationElements(org.androidannotations.internal.model.AnnotationElements) AnnotationElementsHolder(org.androidannotations.internal.model.AnnotationElementsHolder) IRClass(org.androidannotations.rclass.IRClass) ModelProcessor(org.androidannotations.internal.process.ModelProcessor) AndroidManifest(org.androidannotations.helper.AndroidManifest) VersionNotFoundException(org.androidannotations.internal.exception.VersionNotFoundException) ValidationException(org.androidannotations.internal.exception.ValidationException) ProcessingException(org.androidannotations.internal.exception.ProcessingException) AndroidManifestNotFoundException(org.androidannotations.internal.exception.AndroidManifestNotFoundException) IOException(java.io.IOException) VersionMismatchException(org.androidannotations.internal.exception.VersionMismatchException) FileNotFoundException(java.io.FileNotFoundException) RClassNotFoundException(org.androidannotations.internal.exception.RClassNotFoundException)

Example 3 with IRClass

use of org.androidannotations.rclass.IRClass in project androidannotations by androidannotations.

the class AndroidRClassFinder method find.

public IRClass find() throws RClassNotFoundException {
    Elements elementUtils = processingEnv.getElementUtils();
    TypeElement androidRType = elementUtils.getTypeElement("android.R");
    if (androidRType == null) {
        LOGGER.error("The android.R class cannot be found");
        throw new RClassNotFoundException("The android.R class cannot be found");
    }
    LOGGER.info("Found Android class: {}", androidRType.toString());
    return new RClass(androidRType);
}
Also used : RClassNotFoundException(org.androidannotations.internal.exception.RClassNotFoundException) TypeElement(javax.lang.model.element.TypeElement) IRClass(org.androidannotations.rclass.IRClass) Elements(javax.lang.model.util.Elements)

Example 4 with IRClass

use of org.androidannotations.rclass.IRClass in project androidannotations by androidannotations.

the class ProjectRClassFinder method find.

public IRClass find(AndroidManifest manifest) throws RClassNotFoundException {
    Elements elementUtils = environment.getProcessingEnvironment().getElementUtils();
    String rClass = getRClassPackageName(manifest) + ".R";
    TypeElement rType = elementUtils.getTypeElement(rClass);
    if (rType == null) {
        LOGGER.error("The generated {} class cannot be found", rClass);
        throw new RClassNotFoundException("The generated " + rClass + " class cannot be found");
    }
    LOGGER.info("Found project R class: {}", rType.toString());
    return new RClass(rType);
}
Also used : RClassNotFoundException(org.androidannotations.internal.exception.RClassNotFoundException) TypeElement(javax.lang.model.element.TypeElement) IRClass(org.androidannotations.rclass.IRClass) Elements(javax.lang.model.util.Elements)

Aggregations

IRClass (org.androidannotations.rclass.IRClass)4 RClassNotFoundException (org.androidannotations.internal.exception.RClassNotFoundException)3 TypeElement (javax.lang.model.element.TypeElement)2 Elements (javax.lang.model.util.Elements)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 AndroidManifest (org.androidannotations.helper.AndroidManifest)1 AndroidManifestNotFoundException (org.androidannotations.internal.exception.AndroidManifestNotFoundException)1 ProcessingException (org.androidannotations.internal.exception.ProcessingException)1 ValidationException (org.androidannotations.internal.exception.ValidationException)1 VersionMismatchException (org.androidannotations.internal.exception.VersionMismatchException)1 VersionNotFoundException (org.androidannotations.internal.exception.VersionNotFoundException)1 AnnotationElements (org.androidannotations.internal.model.AnnotationElements)1 AnnotationElementsHolder (org.androidannotations.internal.model.AnnotationElementsHolder)1 ModelProcessor (org.androidannotations.internal.process.ModelProcessor)1 AndroidRClassFinder (org.androidannotations.internal.rclass.AndroidRClassFinder)1 CompoundRClass (org.androidannotations.internal.rclass.CompoundRClass)1 ProjectRClassFinder (org.androidannotations.internal.rclass.ProjectRClassFinder)1