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

Fix for multiple build targets at cabal-add #4393

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

VenInf
Copy link
Contributor

@VenInf VenInf commented Aug 30, 2024

Fix for multiple build targets at cabal-add

In my current merged solution, cabal-add CodeAction is provided only for the main target.
This was only a temporary solution due to limitations of the getBuildTargets function.
For more information, consult this thread.

Now it was fixed, and you can choose to what target add the dependency.
Video with an example:

cabal-add-continuation-cut.mp4

Also, I changed the title for the CodeAction, to a hopefully better one.

Implementation details

I changed the functions getBuildTargets and buildTargetComponentName to
the getBuildTargetComponentNames that handles GenericPackageDescription and gives ComponentNames of all targets.

What isn't implemented

  • Previous tests were built assuming that there is need to wait only for one CodeAction. Now this leads to a race condition.

@VenInf VenInf requested a review from fendor as a code owner August 30, 2024 00:10
@VenInf VenInf requested a review from michaelpj as a code owner August 30, 2024 13:06
Copy link
Collaborator

@fendor fendor left a comment

Choose a reason for hiding this comment

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

So, do I understand this correctly, we offer to add the dependency to some dependency, even though we should be able to statically tell to which component the filepath belongs to?

Comment on lines +123 to +126
let runAvait codeAction = do
executeCodeAction codeAction
skipManyTill anyMessage $ getDocumentEdit cabDoc
mapM_ runAvait selectedCas
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let runAvait codeAction = do
executeCodeAction codeAction
skipManyTill anyMessage $ getDocumentEdit cabDoc
mapM_ runAvait selectedCas
let runAvail codeAction = do
executeCodeAction codeAction
skipManyTill anyMessage $ getDocumentEdit cabDoc
mapM_ runAvail selectedCas

Maybe?

@VenInf
Copy link
Contributor Author

VenInf commented Sep 22, 2024

So, do I understand this correctly, we offer to add the dependency to some dependency, even though we should be able to statically tell to which component the filepath belongs to?

Yes, this implementation offers to chose, to what target add the dependency. I think that I can narrow down the list of potential targets using the information from the filepath, but it will take some time to implement. I don't know if it's possible to completely resolve to what target the dependency is related to.
Right now, in current merged solution, there are no resolvers at all.

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