-
-
Notifications
You must be signed in to change notification settings - Fork 388
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
Cabal go to module's definition #4380
Cabal go to module's definition #4380
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, couple of nitpicks, then this should be good to go!
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/CabalFields.hs
Outdated
Show resolved
Hide resolved
…Fields.hs Co-authored-by: fendor <fendor@users.noreply.github.com>
* Add goto-definitions for cabal common sections * Add default direct cradle hie.yaml file to testdata * incorporate changes requested in haskell#4375 * add tests for cabal goto-definition
Noteworthy change: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this looks great! I just have some small comments.
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/CabalFields.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/CabalFields.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/CabalFields.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/CabalFields.hs
Outdated
Show resolved
Hide resolved
Co-authored-by: VeryMilkyJoe <jana.chadt@nets.at>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
If you click go-to definition on the field under `exposed-module` or `other-module` it will open the file where this module was defined. The go-to definition function compares the highlighted text with modules in the cabal file. If there is a match, it takes the respective build target and tries to fetch their `hsSourceDirs` from the `PackageDescription`. (by looking at all `buildInfos` with matching names). After finding them, it constructs a path using directory where the cabal file is located, the info from `hsSourceDirs` and a name of the module converted to a path. If the file exists it returns the `Definition` with the acquired location. --------- Co-authored-by: fendor <fendor@users.noreply.github.com> Co-authored-by: Chrizzl <hochrainer.christoph@gmail.com> Co-authored-by: VeryMilkyJoe <jana.chadt@nets.at>
If you click go-to definition on the field under `exposed-module` or `other-module` it will open the file where this module was defined. The go-to definition function compares the highlighted text with modules in the cabal file. If there is a match, it takes the respective build target and tries to fetch their `hsSourceDirs` from the `PackageDescription`. (by looking at all `buildInfos` with matching names). After finding them, it constructs a path using directory where the cabal file is located, the info from `hsSourceDirs` and a name of the module converted to a path. If the file exists it returns the `Definition` with the acquired location. --------- Co-authored-by: fendor <fendor@users.noreply.github.com> Co-authored-by: Chrizzl <hochrainer.christoph@gmail.com> Co-authored-by: VeryMilkyJoe <jana.chadt@nets.at>
Go to the module's definition
If you click go-to definition on the field under
exposed-module
orother-module
it will open the file where this module was defined.
Video with an example:
go-to-definition-cut.mp4
Implementation details
The go-to definition function compares the highlighted text with modules in the cabal file.
If there is a match, it takes the respective build target and tries to fetch their
hsSourceDirs
from thePackageDescription
. (by looking at allbuildInfos
with matching names).After finding them, it constructs a path using directory where the cabal file is located, the info from
hsSourceDirs
and a name of the module converted to a path.If the file exists it returns the
Definition
with the acquired location.What isn't implemented
if
's