How the GemProcessor looks with a new Annotation Processing Api #13
Replies: 4 comments
-
I've opened Discussions for the tools-gem project and moved this to there. I can see how this can be something interesting for writing annotation processors. The idea of the tools-gem is also tailored towards annotation processor writers that want to reduce their dependency and have type safe access to the value in their annotations. It is a great idea for making it easier for annotation processor From an API perspective I do not like the fact that I need to extend from something. I prefer if I am in control of my structure and can use a composition. I need to play around a bit, but from first sight some things look a bit too verbose to me:
Apart from that, we are trying to keep the dependencies of this project to a minimum. It is a tool to help other library developers, so having as little dependencies is the best. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the Feedback! i can completely understand if you dont want to use the new api for this project. Im fully onboard when it comes to composition over inheritance. The problem with that in this case is, that the jdk api does use inheritance. Keeping this new api close to the jdk one makes it easier to learn for people who already have written annotation processors and it simplifies migrations to the new api. But staying to close the the jdk api makes the new one useless. that is the exact line where the concept of tools-gem itself could help. When getting the value of a annotation field it is not typesave. Convinces methods could remove the need for the i should have left the switch a switch. Would have made the comparison clearer. |
Beta Was this translation helpful? Give feedback.
-
Indeed it felt to me that a concept like the tools-gem would help here to extract the values that are available in the annotations. It of course is not entirely possible to use tools-gem for itself 😄
Yes, I think that it is a bit too long. I think that it would be perfectly fine to have methods like Regarding the
The JDK indeed offers |
Beta Was this translation helpful? Give feedback.
-
a major pain point for me with the jdk api are lines like this TypeElement typeElement = (TypeElement) element;
DeclaredType declaredType = (DeclaredType) typeElement.asType(); you need to know both data structures and how they overlap and there naming even makes it harder at times.
yeah the jdk has 2 options to get annotated elements. i just chose to support only the direct one. |
Beta Was this translation helpful? Give feedback.
-
Hey, to make annotation processors easier to read and write, i built an api around javax.lang.model. One of the processors I migrated to test how the api feels was your GemProcessor. If you like the api i can create a pull request for tools-gem.
Beta Was this translation helpful? Give feedback.
All reactions