开发者

Can we refactor the following scenario using Eclipse?

开发者 https://www.devze.com 2023-02-21 10:53 出处:网络
开发者_如何转开发I want to change the type of a variable from String to int, can we use Eclipse to refactor?There\'s no out of the box refactoring tool that does it as far as I know. The reason probab

开发者_如何转开发I want to change the type of a variable from String to int, can we use Eclipse to refactor?


There's no out of the box refactoring tool that does it as far as I know. The reason probably is that strictly speaking this isn't refactoring: refactoring is a change that doesn't affect the behaviour of the code, but this change definitely does.

Unless you're using reflection, the easiest way to make this change is to change the field first, then watch the bits that turn red, and work your way through them. (You'll get a cascade of errors, pieces that you fix will cause other pieces to go wrong, but eventually you'll get o the end of it.)

I know this isn't really the answer you wanted but if you follow this pattern (deliberately break the code first, then correct errors that arise), it doesn't take long.

If you do have reflection in your code though, then you have no other option than to go through every single file that uses reflection and check whether it would be affected by your change.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号