Fix for multiple build targets at cabal-add
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:
https://github.com/user-attachments/assets/b75587df-e277-48de-8c3c-3fb705b64f32
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
- [x] Previous tests were built assuming that there is need to wait only for one
CodeAction. Now this leads to a race condition.
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.
After a better look at the current implementation, it turned out that target selection was better than expected. Unfortunately, the mechanism isn't properly documented and tested, and I will solve it in a separate PR.