Modifying result of Intellij Structural Search and Replace

Viewed 54

I have a question regarding modifying the result of an intellij search and replace structurally result.

Say I have an enum:

MyEnum FOO = 10; 

System.out.println(MyEnum.FOO)

And I want to replace this, with a new enum called Bar, but the field name includes the value of the previous enum.

Bar FOO_10 = "something else"

What kind of groovy script from the intellij scripting language would I need to use to achieve this?

So the new string is built from an eval of Foo to get 10, and the name of the field Foo, to construct FOO_10.

https://www.jetbrains.com/help/idea/search-templates.html

The documentation on the script constraints is very lacking.

I would need to eval the result of the search query, and use that to build up the replacement string that resolves to the new enum.

We have around 10,000 similar or so references that will need to be changed in the code base.

Thanks

0 Answers
Related