Feature: Extract refactoring #172
Replies: 5 comments 1 reply
-
Hey, It currently only helps with the first let binding extraction example you gave but it's early days yet so I'm aiming to make it as useful as possible. Hope this helps! I appreciate any feedback. |
Beta Was this translation helpful? Give feedback.
-
@dmannock are you planning to contribute it to ionide? |
Beta Was this translation helpful? Give feedback.
-
I ask because the f# community is pretty small and we should always try to work together on stuff. In any case: having more refactorings will always be appreciated. |
Beta Was this translation helpful? Give feedback.
-
@forki Yea sure, I'd love too! It started as a POC to see if it would work easily without using a language server. Since it worked for my use cases, I thought I might as well share it and see if there are any other suggestions/use cases to improve. I then came across this issue which is labelled as 'requires additional upstream functionality'
I'd currently class my extension as 'experimental' and till it covers more use cases wouldn't want to put in in to ionide :) Thanks |
Beta Was this translation helpful? Give feedback.
-
any updates on this, or is there any way to do extract refactor in 2023 in ionide? using this i get most times "no refactorings available" |
Beta Was this translation helpful? Give feedback.
-
The idea is to extract a selected block of code - a function or a value, and give it a name. In case a block is extracted that uses values that are not available in the target scope, they are introduced as parameters (not a problem if it's decided to extract to the parent scope for simplicity). If extracting a part of the string, the correct concatenation is made. If extracting a lambda function the brackets are dropped and
fun
is removed.eg.
selecting
((<>) ' ')
and hitting extract asks for the name, and if given a name "notSpace
", leads to:and
selecting the fold function and hitting extract asks for the name, and if given a name "
collectSignatures
", leads to:On a part of a string:
if "/usr/bin/" is selected, extract is invoked, the name "
prefix
" is given, it results inIdeally this would also replace all occurrences of the extracted block. To make it simpler at first, this feature should probably extract to the immediate outer scope.
Beta Was this translation helpful? Give feedback.
All reactions