jackfirth / resyntax

A Racket refactoring engine
Apache License 2.0
56 stars 10 forks source link

[Feature request] Interactive fix mode #146

Open Metaxal opened 3 years ago

Metaxal commented 3 years ago

It would be nice to have an interactive fix mode, that would allow for applying rules selectively, and avoid cognitive overload by letting the user focus on changes one by one, instead of all at the time.

This mode would display potential fixes just like what analyze does, but then for each fix it would ask, for example,

  1. fix
  2. skip
  3. see in context (opens your editor)
Metaxal commented 3 years ago

For example, I ported a Scheme project to Racket, and resyntax finds lots of potential refactorings (which is pretty neat!). But I'm not sure I want to apply all of them, and I'd like to check them one by one.

jackfirth commented 3 years ago

Are you thinking an interactive fix mode at the command line? Or already in the editor? My general sense is that when I'm doing interactive fixing, I'd probably want to do that by just looking at the code in an editor that highlights any issues detected by Resyntax and clicking a little "fix this one please" button.

Metaxal commented 3 years ago

In the editor would be ideal, but I think it's also valuable (and probably simpler) on the command line. I see it at first as

  1. Analyse the file
  2. Find the next possible fix and pause there.
  3. Propose to fix.
  4. If fix is accepted, apply it, save the file, got to 1, but skip all previously proposed fixes that have been rejected.
  5. Otherwise go to 2. until no more fix.

The re-analysis is not ideal, but at least it's robust and simple to implement. We can think of incremental re-analysis later as an improvement.

jackfirth commented 3 years ago

Would also be handy to have an option to fix the next possible fix and all fixes of the same type, since usually if you want to fix one occurrence of a particular type of problem you probably want to fix all of them.

Metaxal commented 3 years ago

apply / skip / apply-all <rule-name>… / apply none <rule-name> / abort ?