Search in sources :

Example 1 with RoundContext

use of org.robobinding.codegen.apt.RoundContext in project RoboBinding by RoboBinding.

the class ViewBindingProcessor method process.

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    RoundContext roundContext = new RoundContext(roundEnv, processingEnv.getTypeUtils(), processingEnv.getElementUtils(), processingEnv.getMessager());
    Set<WrappedTypeElement> typeElements = roundContext.typeElementsAnnotatedWith(ViewBinding.class, new ViewBindingFilter());
    for (WrappedTypeElement typeElement : typeElements) {
        String viewBindingObjectTypeName = ViewBindingLoader.getViewBindingClassName(typeElement.binaryName());
        ViewBindingInfoBuilder builder = new ViewBindingInfoBuilder(typeElement, viewBindingObjectTypeName);
        ViewBindingInfo info = builder.build();
        Logger log = typeElement.logger();
        try {
            generateViewBindingObjectSourceFile(info, log);
        } catch (IOException e) {
            log.error(e);
            throw new RuntimeException(e);
        } catch (JClassAlreadyExistsException e) {
            log.error(e);
            throw new RuntimeException(e);
        } catch (ClassNotFoundException e) {
            log.error(e);
            throw new RuntimeException(e);
        }
    }
    return true;
}
Also used : JClassAlreadyExistsException(com.helger.jcodemodel.JClassAlreadyExistsException) WrappedTypeElement(org.robobinding.codegen.apt.element.WrappedTypeElement) IOException(java.io.IOException) Logger(org.robobinding.codegen.apt.Logger) RoundContext(org.robobinding.codegen.apt.RoundContext)

Example 2 with RoundContext

use of org.robobinding.codegen.apt.RoundContext in project RoboBinding by RoboBinding.

the class PresentationModelProcessor method process.

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    RoundContext roundContext = new RoundContext(roundEnv, processingEnv.getTypeUtils(), processingEnv.getElementUtils(), processingEnv.getMessager());
    Set<WrappedTypeElement> typeElements = roundContext.typeElementsAnnotatedWith(PresentationModel.class, new PresentationModelFilter());
    for (WrappedTypeElement typeElement : typeElements) {
        String presentationModelObjectTypeName = PresentationModelObjectLoader.getObjectClassName(typeElement.binaryName());
        PresentationModelInfoBuilder builder = new PresentationModelInfoBuilder(typeElement, presentationModelObjectTypeName, true);
        PresentationModelInfo presentationModelInfo = builder.build();
        Logger log = typeElement.logger();
        ProcessingContext context = new ProcessingContext(processingEnv.getTypeUtils(), processingEnv.getElementUtils(), processingEnv.getMessager());
        try {
            if (isItemPresentationModelAlso(typeElement)) {
                createItemPresentationModelObjectSourceFiles(presentationModelInfo, context);
            } else {
                generateAllClasses(presentationModelInfo, context, log);
            }
        } catch (IOException e) {
            log.error(e);
            throw new RuntimeException(e);
        } catch (JClassAlreadyExistsException e) {
            log.error(e);
            throw new RuntimeException(e);
        } catch (ClassNotFoundException e) {
            log.error(e);
            throw new RuntimeException(e);
        }
    }
    return true;
}
Also used : ProcessingContext(org.robobinding.codegen.apt.ProcessingContext) WrappedTypeElement(org.robobinding.codegen.apt.element.WrappedTypeElement) IOException(java.io.IOException) Logger(org.robobinding.codegen.apt.Logger) RoundContext(org.robobinding.codegen.apt.RoundContext) JClassAlreadyExistsException(com.helger.jcodemodel.JClassAlreadyExistsException) PresentationModelInfo(org.robobinding.codegen.presentationmodel.PresentationModelInfo)

Aggregations

JClassAlreadyExistsException (com.helger.jcodemodel.JClassAlreadyExistsException)2 IOException (java.io.IOException)2 Logger (org.robobinding.codegen.apt.Logger)2 RoundContext (org.robobinding.codegen.apt.RoundContext)2 WrappedTypeElement (org.robobinding.codegen.apt.element.WrappedTypeElement)2 ProcessingContext (org.robobinding.codegen.apt.ProcessingContext)1 PresentationModelInfo (org.robobinding.codegen.presentationmodel.PresentationModelInfo)1