Improvements to OCaml code editing: the basics of a refactor engine
1–10 of 21 posts
Re: Improvements to OCaml code editing: the basics of a refactor engine
#2Does it replace identical expressions in the same scope? Like:
let tau = 3.14 +. 3.14
becomes let pi = 3.14
let tau = pi +. pi
?EDIT: Or even crazier with function:
let _ = (x + 1) + (y + 1)
becomes let plus_one a = a + 1
let _ = (plus_one x) + (plus_one y)
(I ask this just out of curiosity. Even the "simpler" version is very impressive!)Re: Improvements to OCaml code editing: the basics of a refactor engine
#3Re: Improvements to OCaml code editing: the basics of a refactor engine
#4Very cool! Does it replace identical expressions in the same scope? Like: let tau = 3.14 +. 3.14 becomes let pi = 3.14 let tau = pi +. pi ? EDIT: Or even crazier with function: let _ = (x + 1) + (y + 1) becomes let plus_one a = a + 1 let _ = (plus_one x) + (plus_one y) (I ask this just out of curiosity. Even the "simpler" version is very impressive!)
let tau =
let pi = 3.14 in
pi + pi
if we extract `pi + pi` it will lead (if you do not give any concrete name) to the following code: let fun_name1 pi =
pi + pi
let tau =
let pi = 3.14 in
fun_name1 piRe: Improvements to OCaml code editing: the basics of a refactor engine
#5Re: Improvements to OCaml code editing: the basics of a refactor engine
#6[dead]
Re: Improvements to OCaml code editing: the basics of a refactor engine
#7The most recent one I’ve made runs 'git grep' on the word under cursor or on the visual selection and puts everything into a quick fix list.
Since it is generic, it works on any phrases as well, and helps me find prose snippets and phrases in docs or other writings.
Re: Improvements to OCaml code editing: the basics of a refactor engine
#8Only thing that would go on my OCD nerve, is the lack of an empty newline when the show_markup function is extracted. Kind of "common sense" when writing top level bindings to leave some breathing room between them.
Re: Improvements to OCaml code editing: the basics of a refactor engine
#9Extract expression is such a common refactoring, happy to see support for it. I'm even more curious to see now if there are going to be more advanced refactoring possible. A List.map, to for loop, and back refactoring would be such a great thing to have in how I program. Only thing that would go on my OCD nerve, is the lack of an empty newline when the show_markup function is extracted. Kind of "common sense" when wr…
For the second point we delay the aeration convention to the formatter (ocamlformat). It can be configure in a different way :)
Thanks for your feedback!