+1 on all features
-----Ursprungligt meddelande-----
Fr�n: Dwight Rodgers [mailto:[EMAIL PROTECTED]]
Skickat: den 26 april 2002 05:01
Till: [EMAIL PROTECTED]
�mne: [Eap-features] Move block into/out of method OR replace all occurences on Extract Method

I often use the "Extract Method" refactoring, only to realize a few seconds later that I wanted to include an extra line or two in the method, or that I should have included one or two fewer lines. To resolve this, I have to use "Inline Method" followed by "Extract Method" again with the new set of lines. Perhaps it would be more convenient to have a single refactoring to push the selected block into a neighboring method of the user's choice, or to pull a selected block out of a method of the user's choice.
 
The latter, I think is the most important. Consider that a user might have a method foo, with three calls to it. The user decides that the beginning 5 lines of foo should be performed differently in each case, and therefore wants to inline those 5 lines out of foo and into the calling locations, but wants to leave the rest of foo unchanged. Without this refactoring he/she would be forced to inline all 3 occurences of foo, then reselect and extract method on the portion of foo that should remain. But IntelliJ will not recognize the other 3 occurrences that were inlined, so he/she will have to manually find the other three inlined locations and manually replace them with calls to the new foo.
 
A more ambitious solution, of course, would be to have IntelliJ recognize that the 3 other inlined versions of foo performed the same function and offer to replace them with calls to foo when the new extract method is performed -- similar to the "Replace All Occurences of Expression" option on "Introduce Variable".
 
Dwight Rodgers
 

Reply via email to