[ACCEPTED]-How to refactor variable type in Eclipse?-refactoring

Accepted answer
Score: 41

How I usually do is that I change one of 7 the upstream variables to long. This causes 6 Eclipse to give error from each assignment 5 where you offer long instead of int. Then 4 I just select ctrl-1 (Quick-fix) on each 3 of them and pick "change variable x to long".

This 2 works when the new type is not directly 1 assignable to the old one.

Score: 24

I don't think you can do this directly using 5 the refactoring tool in Eclipse. However, what 4 you can do is place your cursor over the 3 variable x and hit CTRL + SHIFT + G to find all references 2 in your workspace. This will then allow 1 you to change any dependent references.

Score: 6

IntelliJ has this feature (refactor->type 3 migration), but unfortunately, Eclipse doesn't 2 have it yet. I hope Eclipse will add it 1 soon.

Score: 0

If your field has setter and getter and 7 you have used them in your project, you 6 can first change type of the field manually 5 then refactor its setter and getter methods. e.i. you 4 can change return type of the setter and 3 getter by method refactor.
To refactor a 2 method use:
Open context menu on the method 1 > Refactor > Change method signature

More Related questions