Replace type and rename variable

Hello all,

I have a simple question, but I don't know if it's possible:

I try to refactor a field in my code to a different field. The current field is a Date, and the new type is an Interval. I do, however, not only want to change the type, but also the variable name and the get and set methods.

As an example, This is what I have:


And I want to change this to:


Is this possible, by, for example, using Replace Structually or something?

Thanks,

Erik

5 comments

I think Type Migration does something like this but I've never used it.

Erik Pragt wrote:

Hello all,

I have a simple question, but I don't know if it's possible:

I try to refactor a field in my code to a different field. The current field is a Date, and the new type is an Interval. I do, however, not only want to change the type, but also the variable name and the get and set methods.

As an example, This is what I have:

 private Date date;
> 
> /**
>  * Set the date
>  */
> public void setDate(Date date) {
>   this.date = date;
> }
> /**
>  * Get the date
>  */
> public Date getDate() {
>   return this.date;
> }
> ]]>


And I want to change this to:

 private Interval interval;
> 
> /**
>  * Set the interval
>  */
> public void setInterval(Interval interval) {
>   this.interval = interval;
> }
> /**
>  * Get the interval
>  */
> public Interval getInterval() {
>   return this.interval;
> }
> ]]>


Is this possible, by, for example, using Replace Structually or something?

Thanks,

Erik

0

Keith Lea wrote:

I think Type Migration does something like this but I've never used it.


I've tried to use Type Migration to do this in the past and it always tells me: "No
alternatives found"

Tim

0

Great, a 'feature' that's not in my Refactor Menu...

I only have:

]]>


:(

0

Erik Pragt wrote:

Great, a 'feature' that's not in my Refactor Menu...

Migrate...


There it is...

0

Erik Pragt wrote:

Great, a 'feature' that's not in my Refactor

Menu...

Migrate...


There it is...


Not according to this : http://kano.net/idea-actions/

Migrate only seems to be able to changes packages and classes (eg Swing 1.0.3 -> 1.1) . That's not what I want. (see above)

0

Please sign in to leave a comment.