workspace command: extract an expression to a function
Opened this issue · 0 comments
NJichev commented
A workspace command that extracts a selected expression to a private function:
Example:
defmodule Example do
def run() do
n = 2
|m = n + 2
# Calculate
k = m + n|
g = 3
end
end
Selecting the specified region between the pipes should result in:
defmodule Example do
def run(list) do
n = 2
fun(n)
g = 3
end
defp fun(n) do
m = n + 2
# Calculate
k = m + n
end
end
Consider the following scenarios:
- Any unbound variables in this expression should become extra arguments to the function and be passed from the caller