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

Be much more intelligent about splitting matches #1543

Merged
merged 17 commits into from
Mar 11, 2021

Conversation

isovector
Copy link
Collaborator

@isovector isovector commented Mar 9, 2021

Wingman used to implement case split by guessing where in the AST the match group was, and then annotating from there. But this had lots of problems --- it wouldn't work in where bindings, or class defaults. And I'd hand-coded support for instance methods, but due to a bug it would reformat the entire declaration.

This PR adds some new syb traversals that let us target very specific parts of the AST. For example, it's now possible to target "the smallest MatchGroup that contains a given source span," and then run a list-bind over its Matches. The machinery is reusable for other purposes, and makes the Graft system more composable.

Fixes #1542
Fixes #1541
Fixes #1516

@isovector isovector marked this pull request as draft March 9, 2021 22:46
@isovector isovector marked this pull request as ready for review March 10, 2021 00:51
Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

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

lgtm if it does for you

Copy link
Collaborator

@konn konn left a comment

Choose a reason for hiding this comment

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

Thank you for refactorings in graftWith* families. I like them!

ghcide/src/Development/IDE/GHC/ExactPrint.hs Show resolved Hide resolved
ghcide/src/Development/IDE/GHC/ExactPrint.hs Show resolved Hide resolved
ghcide/src/Development/IDE/GHC/ExactPrint.hs Show resolved Hide resolved
@isovector isovector added the merge me Label to trigger pull request merge label Mar 10, 2021
Copy link
Collaborator

@konn konn left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@mergify mergify bot merged commit 12bcb50 into haskell:master Mar 11, 2021
@isovector isovector deleted the graft-better branch April 5, 2021 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
3 participants