-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: LSP hover and go-to-definition for crates (#5786)
# Description ## Problem Resolves #5787 ## Summary This is a minor thing, but hover and go-to-definition didn't work in path segments that referred to crates. For completeness, and for features we could build later on (for example making auto-import insert new stuff inside existing paths if possible) I thought it would be nice to have this working. ![lsp-crate](https://github.com/user-attachments/assets/be6d4308-6387-45c4-aac8-66459d15b746) ## Additional Context While doing it some code got simplified: the part of a path that referred to a crate didn't refer to anything (None) and that was the only case where an Option was needed. Now that we capture all references that None is gone. I know we are kind of capturing module attributes twice, one in the def maps and another in NodeInterner, but otherwise getting a Location from a ReferenceId would also need def maps to be passed to NodeInterner, which is a bit less convenient. In any case this information was tracked like that already, it's just that it was missing for modules that were crate roots. Note that the information is still missing for the root module of the root crate, so that case is handled separately in a couple of places. Capturing this is doable, but I didn't know where to get the root crate name from in `CrateDefMap::collect_defs`. ## Documentation Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
- Loading branch information
Showing
14 changed files
with
121 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.