This content has been marked as final. Show 1 reply
coconut99_99 wrote:The visitor structure in apt is a bit awkard and much improved in JSR 269. If you can use JDK 6, I recommend switching to javac and javax.annotation.processing and javax.lang.model.* instead of using apt.
Question: How to perform actions that are called when the visits to members of a class is finished?
Currently, DeclarationVisitor have visit functions for members of a class, but there doesn't seem to be an interface that is called AFTER all members of the class has been visited. Is there is a function like visitFinished () or like that?
Without this interface, it forces developers to write some code twice: once in the AnnotationProcessor and again inside DeclarationVisitor to detect and deal with new definitions of Enums / Classes / Nested classes, which is really bad.
With that said, to get sequencing on the apt era visitors, you can use
to return a visitor that gets called in a fixed iteration order. The annotation processor should generally just be the outermost loop iterating over the types from the input files.