Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revamp insert missing cases code action #804

Merged
merged 3 commits into from
Aug 16, 2023
Merged

Conversation

zth
Copy link
Collaborator

@zth zth commented Aug 16, 2023

This revamps the current "Insert missing cases" code action by leveraging actual AST transforms to produce the updated switch code instead of relying on unstable and ad hoc string parsing. This is now possible thanks to the compiler printing the cases in ReScript syntax rather than OCaml syntax.

Example:
image
image
image

…oduce the missing cases and insert them into the existing switch
@zth zth requested a review from cristianoc August 16, 2023 13:21
@zth zth mentioned this pull request Aug 16, 2023
Copy link
Collaborator

@cristianoc cristianoc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much more solid now.

@@ -392,6 +392,14 @@ let test ~path =
Printf.printf "%s\nnewText:\n%s<--here\n%s%s\n"
(Protocol.stringifyRange range)
indent indent newText)))
| "c-a" ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's c-a?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unambiguous but getting a bit cryptic

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's "codemod - AddMissingCases" 😅 Might be make more sense to have the codemod variant derived from the rest of the string too...

@zth zth merged commit c36e79f into master Aug 16, 2023
5 checks passed
@zth zth deleted the revamp-insert-missing-cases branch August 16, 2023 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants