diff options
Diffstat (limited to 'container-compiler-plugin/src/main/java/io/trygvis/container/compiler/MyProcessor.java')
-rw-r--r-- | container-compiler-plugin/src/main/java/io/trygvis/container/compiler/MyProcessor.java | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/container-compiler-plugin/src/main/java/io/trygvis/container/compiler/MyProcessor.java b/container-compiler-plugin/src/main/java/io/trygvis/container/compiler/MyProcessor.java index 6843659..735d688 100644 --- a/container-compiler-plugin/src/main/java/io/trygvis/container/compiler/MyProcessor.java +++ b/container-compiler-plugin/src/main/java/io/trygvis/container/compiler/MyProcessor.java @@ -1,6 +1,7 @@ package io.trygvis.container.compiler; import io.trygvis.container.log.Log; +import io.trygvis.persistence.SqlEntity; import org.springframework.transaction.annotation.Transactional; import javax.annotation.processing.Completion; @@ -31,19 +32,16 @@ public class MyProcessor implements Processor { @Override public Set<String> getSupportedOptions() { - System.out.println("io.trygvis.container.compiler.MyProcessor.getSupportedOptions"); return emptySet(); } @Override public SourceVersion getSupportedSourceVersion() { - System.out.println("io.trygvis.container.compiler.MyProcessor.getSupportedSourceVersion"); return SourceVersion.RELEASE_7; } @Override public void init(ProcessingEnvironment processingEnv) { - System.out.println("io.trygvis.container.compiler.MyProcessor.init"); this.processingEnv = processingEnv; elements = processingEnv.getElementUtils(); types = processingEnv.getTypeUtils(); @@ -51,13 +49,11 @@ public class MyProcessor implements Processor { @Override public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) { - System.out.println("io.trygvis.container.compiler.MyProcessor.getCompletions"); return emptyList(); } @Override public Set<String> getSupportedAnnotationTypes() { - System.out.println("io.trygvis.container.compiler.MyProcessor.getSupportedAnnotationTypes"); return new HashSet<>(asList( Transactional.class.getName(), Log.class.getName(), @@ -66,34 +62,39 @@ public class MyProcessor implements Processor { @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { - System.out.println("io.trygvis.container.compiler.MyProcessor.process"); - System.out.println("annotations = " + annotations); -// Set<? extends Element> transactional = roundEnv.getElementsAnnotatedWith(Transactional.class); + try { + return work(annotations, roundEnv); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + public boolean work(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws Exception { TypeElement tx = elements.getTypeElement(Transactional.class.getCanonicalName()); TypeElement log = elements.getTypeElement(Log.class.getCanonicalName()); TypeElement entity = elements.getTypeElement(Entity.class.getCanonicalName()); + EntityHandler entityHandler = new EntityHandler(processingEnv); + + Set<? extends Element> sqlEntities = roundEnv.getElementsAnnotatedWith(SqlEntity.class); + entityHandler.phase1(sqlEntities); + for (Element element : roundEnv.getRootElements()) { - try { - System.out.println("Processing: " + element); - for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) { - DeclaredType annotationType = annotationMirror.getAnnotationType(); - - if (types.isSameType(tx.asType(), annotationType)) { - new TransactionalHandler(processingEnv).processTransactional((TypeElement) element); - } - if (types.isSameType(log.asType(), annotationType)) { - new LogHandler(processingEnv).processLog((TypeElement) element); - } - if (types.isSameType(entity.asType(), annotationType)) { - new EntityHandler(processingEnv).processEntity((TypeElement) element); - } + System.out.println("Processing: " + element); + for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) { + DeclaredType annotationType = annotationMirror.getAnnotationType(); + + if (types.isSameType(tx.asType(), annotationType)) { + new TransactionalHandler(processingEnv).processTransactional((TypeElement) element); + } + if (types.isSameType(log.asType(), annotationType)) { + new LogHandler(processingEnv).processLog((TypeElement) element); + } + if (types.isSameType(entity.asType(), annotationType)) { + entityHandler.processEntity((TypeElement) element); } - } catch (RuntimeException e) { - throw e; - } catch (Exception e) { - throw new RuntimeException(e); } } return true; |