Can I programatically rename fields?

Due to a mistake in coding style guidelines I would like to rename a lot of the variables in my project. I can change each one using a regular expression, but is there a way of limiting it to only changing variables (specifically fields)? I thought that I would be able to do this with the structural search, but it seems that isn't the case.

If there isn't an easy way, how hard would it be to write a plugin that renames variables? I have never written a plugin before :)

David

1 comment
Comment actions Permalink

Hello David,

Due to a mistake in coding style guidelines I would like to rename a
lot of the variables in my project. I can change each one using a
regular expression, but is there a way of limiting it to only changing
variables (specifically fields)? I thought that I would be able to do
this with the structural search, but it seems that isn't the case.

If there isn't an easy way, how hard would it be to write a plugin
that renames variables? I have never written a plugin before :)


It's easy to write a plugin to do this. You can use RefactoringFactory.createRename()
to initiate a rename refactoring programmatically.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Please sign in to leave a comment.