Skip to content

gp-pereira/refactorex

Repository files navigation

Refactorex for VS Code

Uses the Refactorex language server to enhance VS Code with code actions to quickly refactor Elixir.

Example

Available refactorings

Scope Refactoring Target Published?
alias Sort aliases selection
alias Merge aliases selection
alias Expand aliases selection
constant Extract constant selection
constant Inline constant selection
constant Rename constant selection
function Expand anonymous function selection
function Extract anonymous function selection
function Extract function selection
function Inline function selection
function Rename function selection
function Underscore unused args line
function Use keyword syntax line
function Use regular syntax line
guard Extract guard selection
guard Inline guard selection
guard Rename guard selection
if else Use keyword syntax line
if else Use regular syntax line
pipeline Introduce IO.inspect selection
pipeline Introduce pipe line
pipeline Remove IO.inspect line
pipeline Remove pipe line
variable Extract variable selection
variable Inline variable selection
variable Rename variable selection

How to use each refactoring

Function: expand anonymous function

  • Description: expand an anonymous function from & to fn -> end syntax
  • Works on: anonymous function selection

Example

▲ top


Function: extract anonymous function

  • Description: extract the anonymous function into a private function
  • Works on: anonymous function selection

Example

▲ top


Function: extract function

  • Description: extract the selection into a private function
  • Works on: selection

Example

▲ top


Function: underscore unused args

  • Description: places an underscore in front of function args not used.
  • Works on: function definition line or function clause line

Example

▲ top


Function: use keyword syntax

  • Description: rewrite the regular function (do end) using keyword syntax (, do:)
  • Works on: function definition line

Example

▲ top


Function: use regular syntax

  • Description: rewrite the keyword function (, do:) using regular syntax (do end)
  • Works on: function definition line

Example

▲ top


Pipeline: pipe first arg

  • Description: pipe the first arg into call
  • Works on: line

Example

▲ top


Pipeline: remove pipe

  • Description: remove the pipe operator and put first arg inside call
  • Works on: pipe line

Example

▲ top


Variable: extract constant

  • Description: extract the selection into a module constant
  • Works on: selection

Example

▲ top