Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The public visit(ASTNode[], SourceUnit) method is invoked for each source unit that contains your target annotationcalled once per annotated node (class, method, or field; method parameters don't seem to be supported). The first element in the ASTNode array holds the annotation, the second one the annotated node. The AST you receive is not for the @WithLogging annotated method, it is for the entire file that contains @WithLogging. This example is just using findAll to locate methods that are annotated with @WithLogging, then using an each statement to wrap any annotated method with print lines. A method to the compiler is simply a list of Statement objects, so the example adds a statement zero logging the start message and appending a statement to the list with the end message.

...