Skip to content

Suggestion: "extract variable" and "inline variable" refactoringsΒ #3750

@cmeeren

Description

@cmeeren

"Variable" might be the wrong name, but you get the picture.

Given the following code:

<code before>
let bar = foo |> doSomething param1 param2 param3 |> thenSomethingElse
<code after>

I frequently want to hightlight any valid sub-expression, say doSomething param1 param2 param3, and press a keyboard shortcut to get this:

<code before>
let curried = doSomething param1 param2 param3
let bar = foo |> curried |> thenSomethingElse
<code after>

Naturally, upon execution, this refactor will end up in a rename operation on the name of the extracted value so that I can pick one myself.

I realize also that some decision will need to be taken if you try to extract something from a one-liner, e.g.

let foo = somethingToExtract somethingElse

might become

let foo = 
  let bar = somethingToExtract
  bar somethingElse

Furthermore, I frequently have need for the exact opposite: Place the caret on a variable name and use a hypothetical "inline variable" refactoring to inline the definition everywhere it's used.

In sum, these are probably the refactorings I miss the most when working in F#.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions