Use AnnotationService to get all annotations

MSAL

Replace the deprecated getAllAnnotations() of J.ClassDeclaration and J.MethodDeclaration with service(AnnotationService.class).getAllAnnotations(Cursor) in a JavaVisitor. The visitor's own cursor is used when the declaration is the one it is visiting, and a cursor to the declaration otherwise. A private static helper method of the visitor becomes an instance method, when only the visitor's own instance methods call it. Other calls outside a JavaVisitor have no cursor and are left alone.

org.openrewrite.java.recipes.UseAnnotationServiceForAllAnnotations
mod run . --recipe=org.openrewrite.java.recipes.UseAnnotationServiceForAllAnnotations

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.