al-codeactions
al-codeactions copied to clipboard
Extract procedure for duplicate code (request)
Often the extract procedure function is used to eliminate duplicate code.
What about the following ideas:
-
Extract procedure automatically matches the generated procedure with an existing procedure and suggests to use this already existing procedure. or ( I think this might be harder to realise) when the procedure NewProcedure is renamed to the name of the same procedure with the same signature the NewProcedure is not created ( duplicate )
-
allow multiple cursor feature to select multiple occurences of the same lines that can be extracted to one NewProcedure which is called multiple times.
Hi Peter, I understand the requirements, but have to see what I can do for you. Currently I rarely find time to develop, so no promises, but I'll have it in mind next time I look into it.
What would be if after the first extraction a pop up would show up telling you that there are more occurences of exactly the same code and asks you if they should be replaced as well (Yes/No)? If no code could be found that is exactly the same, then of course the pop pu wouldn't show up.
May be the other way around? If the extracted procedure would duplicate an existing procedure you could pop up a question if the existing procedure needs to be re-used? (so option 1) . This seems to be less work for you.
Otherwise your suggestion is ok