-
-
Notifications
You must be signed in to change notification settings - Fork 411
Cabal go to module's definition #4380
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
Conversation
fendor
left a comment
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 <[email protected]>
* 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: |
VeryMilkyJoe
left a comment
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
fendor
left a comment
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 <[email protected]> Co-authored-by: Chrizzl <[email protected]> Co-authored-by: VeryMilkyJoe <[email protected]>
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 <[email protected]> Co-authored-by: Chrizzl <[email protected]> Co-authored-by: VeryMilkyJoe <[email protected]>
Go to the module's definition
If you click go-to definition on the field under
exposed-moduleorother-moduleit 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
hsSourceDirsfrom thePackageDescription. (by looking at allbuildInfoswith matching names).After finding them, it constructs a path using directory where the cabal file is located, the info from
hsSourceDirsand a name of the module converted to a path.If the file exists it returns the
Definitionwith the acquired location.What isn't implemented
if's