Can Intellij Do this for me??

I have a variable x that has getters and setters. the current type is string and I want to change it to boolean. Can intellij change it and the getters/setters for me automatically??

6 comments
Comment actions Permalink

I don't think so, this would be a good feature request. It could probably be done as part of the Change Method Signature action.

0
Comment actions Permalink

I don't think it could automatically take care of the conversion between
types in all cases, so it doesn't do it for you. As far as I know, anyway.

In such cases, I usually perform the following steps:
- perform the encapsulate fields refactoring for the field (so to get rid of
direct access, even from the class the field belongs to);
- manually change the type of the field (slightly changing it's name, so you
don't get conflicts for the getters in the next step);
- create getters and setters for the field of new type
- change the old getters and setters to use the new ones (perform the
conversion manually);
- inline the old getters and setters
- optionally, rename the new field to the old name.

A refactoring where it would ask for the conversion strategy might be a nice
addition, though. :)

HTH,
Andrei

"charles decroes" <spam@decroes.com> wrote in message
news:19500559.1076530583326.JavaMail.itn@is.intellij.net...

I have a variable x that has getters and setters. the current type is

string and I want to change it to boolean. Can intellij change it and the
getters/setters for me automatically??


0
Comment actions Permalink

charles decroes wrote:

I have a variable x that has getters and setters. the current type is string and I want to change it to boolean. Can intellij change it and the getters/setters for me automatically??


Nope, not currently. It would be very nice if it did. As Keith
mentions as part of the change method sig action, which should also
allow to change the throws clause as part of the sig... and doesn't.

R

0
Comment actions Permalink

In article <c0e3u5$r07$2@is.intellij.net>,
"Robert S. Sfeir" <robert@codepuccino.com> wrote:

charles decroes wrote:

I have a variable x that has getters and setters. the current type is
string and I want to change it to boolean. Can intellij change it and the
getters/setters for me automatically??


Nope, not currently. It would be very nice if it did. As Keith
mentions as part of the change method sig action, which should also
allow to change the throws clause as part of the sig... and doesn't.


+1

Scott

0
Comment actions Permalink

+10. Just yesterday I've changed 5 files by hand when simple "Change variable type" refactoring could be applied, it existed.

0
Comment actions Permalink

i was trying to change boolean to Boolean which is very simple just a pain to have to do it manually

0

Please sign in to leave a comment.