spring-framework
spring-framework copied to clipboard
Improve the deprecation experience for ContentResultMatchersDsl.json
Problem Statement
It can be tedious to fix all of the deprecation warnings you get from using json(jsonContent, strict = true). It's not as easy as a find-and-replace, because it requires an import. Also, in my experience, an AI agent will be extremely likely to mess it up somehow (at least Copilot on a large project).
Solution
The Kotlin @Deprecation annotation has support for automatically replacing deprecated code with the new, supported code. I have modified the annotation on this method so that users can automatically upgrade.
Testing evidence
Here are some screenshots showing how this works in Intellij Idea:
-
Original deprecated code.
-
The deprecation message now has a button you can click to replace the code.
-
After performing the automatic replacement. Note that the code compiles, but has a warning.
-
Intellij offers to automatically fix the warning. This can be applied to the entire file or project at once if there are multiple occurrences.
-
Done.