Skip to content

Code actions for exhaustive switches #812

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

Merged
merged 3 commits into from
Aug 18, 2023
Merged

Code actions for exhaustive switches #812

merged 3 commits into from
Aug 18, 2023

Conversation

zth
Copy link
Collaborator

@zth zth commented Aug 18, 2023

This introduces a code action for inserting an exhaustive switch. Works for variants, polyvariants, options, and bools. It can be triggered in the following ways:

Putting the cursor on an identifier

ca-es-identifier.mov

Selecting an expression

ca-es-selection.mov

@zth zth requested a review from cristianoc August 18, 2023 18:12
Comment on lines +781 to +786
(match findThisExprLoc with
| Some loc when expr.pexp_loc = loc -> (
match exprToContextPath expr with
| None -> ()
| Some ctxPath -> setResult (Cpath ctxPath))
| _ -> ());
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is pretty messy to include like this in the existing autocomplete. But, it's a pretty valuable feature, and this part of the code base needs a big refactor soon anyway, so I think it's OK given what it enables.

@zth zth merged commit 09fd729 into master Aug 18, 2023
@zth zth deleted the more-exhaustive-switches branch August 18, 2023 19: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