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

Let LSP hover and go-to-definition work on path segments that refer to a crate #5787

Closed
asterite opened this issue Aug 21, 2024 · 0 comments · Fixed by #5786
Closed

Let LSP hover and go-to-definition work on path segments that refer to a crate #5787

asterite opened this issue Aug 21, 2024 · 0 comments · Fixed by #5786
Labels
enhancement New feature or request

Comments

@asterite
Copy link
Collaborator

Problem

Right now given a path like foo::bar::baz in code, LSP lets you navigate or get hover information on any of those segments except when the first segment refers to a crate.

Happy Case

LSP works for the crate segment too.

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

None

Blocker Context

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@asterite asterite added the enhancement New feature or request label Aug 21, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Aug 21, 2024
github-merge-queue bot pushed a commit that referenced this issue Aug 22, 2024
# 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.
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant