ppx_refactor is a small ppx tool that make it easy to create local code refactoring that preserve the layout of files being rewritten.
ppx_refactor uses the same idea as camlp4-to-ppx. This is how it works:
- it parses the input file using the OCaml parser
- it apply the user-defined refactoring which records text substitution based on locations
- it applies the text substitution on the original file
To define a refactoring, one essentially has to write a small piece of OCaml code that uses the ppx_refactor API.