Parameterize raw Collection-typed local variables

Proprietary

Infers a single element type for raw single-arg-generic java.util.Collection local variables (List, Set, Collection, Queue, Deque, Iterable) from the arguments passed to their add(..) calls and rewrites the declaration to use that type. Initializers are rewritten to use the diamond operator. The original LHS interface and RHS implementation class are preserved. Prototype scope: single-variable declarations, no alias or escape tracking.

org.openrewrite.analysis.java.dataflow.ParameterizeRawCollection
mod run . --recipe=org.openrewrite.analysis.java.dataflow.ParameterizeRawCollection

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