mass rename
Hi
Does there exist any relatively easy way to perform a mass fields rename in IDEA?
We have lots of fields that we want to rename from THIS_NOTATION to thisNotation.
I was able to compose a structural search&replace query that finds them all, and now I need a script that will do the renaming (with all the usages of course).
Is it possible at all? Any hints please?
Thanks
请先登录再写评论。
Hi Konstantin,
'Structural search and replace' allows not only searches but replaces as well. Why don't you want to use it for that?
Denis
On Thu, 08 Dec 2011 07:57:41 MSK, Konstantin Sobolev
<konstantin.sobolev@gmail.com> wrote, quoted or indirectly quoted
someone who said :
>Does there exist any relatively easy way to perform a mass fields rename in IDEA?
>We have lots of fields that we want to rename from THIS_NOTATION to thisNotation.
>I was able to compose a structural search&replace query that finds them all, and now I need a script that will do the renaming (with all the usages of course).
>Is it possible at all? Any hints please?
Shift-F6 finds all uses and renames. You can optionally rename is
comments too.
For renaming large numbers of variables, you might want a regex.
You might use an external utility. See
http://mindprod.com/jgloss/search/replace.html
to which you can feed a script.
Sometimes the easiest way to handle these is to write a one-shot Java
program that does a custom search replace. It can do something clever
to transform.
See http://mindprod.com/products1.html#EXTRACT
for a program you can use as a base that does just the regex search
part over a constellation of files.
See http://mindprod.com/jgloss/regex.html
for hot to write the replace code.
--
Roedy Green Canadian Mind Products
http://mindprod.com
For me, the appeal of computer programming is that
even though I am quite a klutz,
I can still produce something, in a sense
perfect, because the computer gives me as many
chances as I please to get it right.
because it does a replace, not a rename. Usages don't get updated.
I thought I could do it with some script in the 'replace' part, like take found PSI node and call Rename refactoring on it.
Thanks, but it's not any better than simple shell scripting with grep and sed. I was hoping to leverage IDEA's rename refactoring
ok nevermind.. bash+awk+perl and a little hand-editing did it.