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

hls-class-plugin - Add placeholders for all class methods #3394

Merged
merged 10 commits into from
Dec 27, 2022

Conversation

batkot
Copy link
Contributor

@batkot batkot commented Dec 12, 2022

Added code action for creating placeholders for all not implemented class methods. Action is skipped when only required methods are missing to avoid duplication.

Currently it's available only when minimal class definition is not met, wasn't sure how to locate class instances 🤔

missing-placeholders

Close #3017

@batkot batkot requested a review from Ailrun as a code owner December 12, 2022 23:45
Copy link
Member

@Ailrun Ailrun left a comment

Choose a reason for hiding this comment

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

I don't have enough time at least for now, sorry for the delay. This is some minor comment. Hopefully I could have some timespan soon for a fuller review.

$ fmap (filter (\(bind, _) -> bind `notElem` implemented))
$ minDefToMethodGroups range sigs
$ classMinimalDef cls
$ nubBy (\(_, x) (_,y) -> x == y)
Copy link
Member

Choose a reason for hiding this comment

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

The performance is probably better with nubOrdOn snd instead of this.

Suggested change
$ nubBy (\(_, x) (_,y) -> x == y)
$ nubOrdOn snd

@michaelpj
Copy link
Collaborator

Maybe @July541 could take a look?

@July541
Copy link
Collaborator

July541 commented Dec 19, 2022

I can do a review this weekend if @Ailrun is busy still.

Copy link
Collaborator

@July541 July541 left a comment

Choose a reason for hiding this comment

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

Many thanks for your improvement! please add tests for it robust.

@July541
Copy link
Collaborator

July541 commented Dec 25, 2022

Currently it's available only when minimal class definition is not met, wasn't sure how to locate class instances 🤔

class-plugin relies on ghc diagnostic to produce code actions, you can't have code actions for all instances under the current mechanism.

isClassMethodWarning :: T.Text -> Bool
isClassMethodWarning = T.isPrefixOf "• No explicit implementation for"

@batkot
Copy link
Contributor Author

batkot commented Dec 27, 2022

Thanks for review, @July541 👍

class-plugin relies on ghc diagnostic to produce code actions, you can't have code actions for all instances under the current mechanism.

Yeah I noticed that, I was just wondering if there's a nicer way to do that 🤔 But I don't know GHC codebase that well (not to say at all) 😅

Copy link
Collaborator

@July541 July541 left a comment

Choose a reason for hiding this comment

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

Everything looks fine, thank you for your work!

@July541 July541 added the merge me Label to trigger pull request merge label Dec 27, 2022
@July541
Copy link
Collaborator

July541 commented Dec 27, 2022

I was just wondering if there's a nicer way to do that

I think we can ignore diagnostics and emit the code actions directly.

@mergify mergify bot merged commit 6e76fce into haskell:master Dec 27, 2022
@batkot batkot deleted the 3017-all-class-methods branch December 27, 2022 22:23
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
Development

Successfully merging this pull request may close these issues.

Add placeholders for all class instance methods
4 participants