Use AnnotationService to get all annotations
MSALReplace 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. UseAnnotationServiceForAllAnnotationsmod run . --recipe= org. openrewrite. java. recipes. UseAnnotationServiceForAllAnnotationsInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.