Refactoring. Find&Replace method code duplicates.
I'm wondering what the new feature ' Refactoring. Find&Replace method code
duplicates. ' does exactly?
It sounds great but so far all I get is "idea has not found any code that
can be replaced with method call".
-- Glen
Please sign in to leave a comment.
It will pick any duplication of the portion of code elsewhere in the same file and replace it with a call to the extracted method.
However I found it very restrictive. It seems to only pick up exact duplicate (don't get me wrong, it is already something. It just needs to be improved).
Simple this like that
It won't pick the other one if I try to extract both lines in one of the method. Intuitively I thought it would do this
Unfortunately not.
The restrictive to only search the current page is also sub-optimal. Sometimes you know that something like this must exist, even already factored. It would be nice to have the option to run a configurable duplication analysis with the same tuning option as the global analysis.
Jacques
Does it really work only in the same file??? This would be a very hard
limitation!
Tom
Thomas Singer (MoTJ) wrote:
>> It will pick any duplication of the portion of code elsewhere in the same
>> file and replace it with a call to the extracted method.
Yes, that is right - unfortunately.
Friendly,
Dmitry
--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"
Jacques Morel wrote:
The point of this refactoring is that it does not extract any method.
To do what you want to do, you should introduce a parameter for "1" in
method1().
Friendly,
Dmitry
That will be great indeed. We will surely have this in 5.0.
Friendly,
Dmitry
--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"
Why only for the file? Would it require too much effort or would it be
too slow?
Tom
Thomas Singer (MoTJ) wrote:
>> Yes, that is right - unfortunately.
It will requre too much effort to make it not too slow :)
Friendly,
Dmitry
--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"