The Type Migration refactoring allows you to automatically change a member type (e.g. from integer to string), and data flow dependent type entries, like method return types, local variables, parameters etc. across the entire project. It also lets automatically convert variable or method return type between arrays and collections. If any conflicts are found IntelliJ IDEA warns you about them.
f: int -> String
I<String> -> I<Integer>
myResult: ArrayList<String> -> String
To change type, follow these steps
- In the editor, place the caret on the type to be refactored.
- On main menu, choose , or press Ctrl+Shift+F6.
- In the Type Migration dialog box, specify the new type and scope where to look for the usages.
- Click Preview and review the items that will be affected. If needed, exclude usages from refactoring. To do that, right-click usage in the Type Migration Preview and select Exclude. When done, click Migrate.