https://github.com/t1/extended-annotation-processor
simplifies writing annotation processors
https://github.com/t1/extended-annotation-processor
Last synced: 12 months ago
JSON representation
simplifies writing annotation processors
- Host: GitHub
- URL: https://github.com/t1/extended-annotation-processor
- Owner: t1
- License: apache-2.0
- Created: 2015-08-11T04:32:24.000Z (almost 11 years ago)
- Default Branch: trunk
- Last Pushed: 2025-04-11T18:46:42.000Z (over 1 year ago)
- Last Synced: 2025-04-11T19:49:40.243Z (over 1 year ago)
- Language: Java
- Homepage:
- Size: 346 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
= ExAP - Extended Annotation Processor image:https://github.com/t1/extended-annotation-processor/actions/workflows/maven.yml/badge.svg[link=https://github.com/t1/extended-annotation-processor/actions/workflows/maven.yml]
The https://docs.oracle.com/javase/8/docs/api/javax/annotation/processing/Processor.html[Java Annotation Processor API] is a powerful tool to execute custom code when `javac` runs. But the API is ... quite implementation oriented. This project tries to provide an alternative API that is more for the writers of annotation processors.
For example, to mark an element with an error, in the standard API you'd have to:
[source,java]
----
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "this is wrong", element);
----
The extended annotation processor offers this functionality directly at the element:
[source,java]
----
element.error("this is wrong");
----
See the test module for a working example.
== Unit Testing
The second big feature is that you can unit-test most of your annotation processor. While this can not cover 100% (e.g. there is no way to access the javadoc comments at runtime), it's very helpful to have short feedback cycles for the parts that you work most at. See the https://github.com/t1/extended-annotation-processor/blob/master/extended-annotation-processor/src/test/java/com/github/t1/exap/reflection/ReflectionTest.java[`ReflectionTest`] class for an example.
== Status
This project still has some way to go to be considered feature complete. But it may already prove useful to most annotation processor projects you have at hand.