Java – How to search and replace structurally in Intellij

ideintellij-ideajavastructural-search

I am migrating my Junit tests from Junit v3 to Junit v4.

I was hoping to use the search and replace structurally "srs" to add an @Test annotation before all methods starting with test.* using my favorite IDE Intellij.

I just cant figura out how to do it… I can create a query that will find all methods without an annotation (there is an example bundled in Intellij) but when used to do a replace either my class gets replaced by only the method names OR nothing is found.

Maybe a regexp is easier 🙂

Best Solution

It is not possible, as of now, but there are requests for class members replacements.

Here is a useful link for getting started with ssr: https://www.jetbrains.com/idea/docs/ssr.pdf