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

LSP "rename struct" misses a few location #5394

Closed
asterite opened this issue Jul 3, 2024 · 0 comments · Fixed by #5404
Closed

LSP "rename struct" misses a few location #5394

asterite opened this issue Jul 3, 2024 · 0 comments · Fixed by #5404
Assignees
Labels
bug Something isn't working

Comments

@asterite
Copy link
Collaborator

asterite commented Jul 3, 2024

Aim

LSP "rename struct" should refactor all occurrences of a struct. Right now that's not the case.

Expected Behavior

Given this program:

struct Foo {
  field: Field,
}

impl Foo {
  fn foo() {}
}

fn main() {
  Foo::foo(); // <-- this "Foo" isn't renamed
}

fn foo() -> Foo { // <-- this "Foo" isn't renamed
}

when I right-click in "Foo", choose "Rename symbol" and choose another name. All "Foo" are renamed.

Bug

The "Foo"s marked at the given locations aren't renamed when trying to rename "Foo". So, essentially:

  • "Foo" showing up in the middle of a "path"
  • "Foo" in a return type

To Reproduce

No response

Project Impact

Blocker

Impact Context

No response

Workaround

None

Workaround Description

No response

Additional Context

No response

Installation Method

None

Nargo Version

No response

NoirJS Version

No response

Would you like to submit a PR for this Issue?

Yes

Support Needs

No response

@asterite asterite added the bug Something isn't working label Jul 3, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Jul 3, 2024
@asterite asterite self-assigned this Jul 3, 2024
github-merge-queue bot pushed a commit that referenced this issue Jul 3, 2024
# Description

## Problem

Resolves #5393

## Summary

Implements "Find all references". The logic for it is the same as the
one for "Rename symbol" so it was straight-forward to do.


https://github.com/noir-lang/noir/assets/209371/5eef03bf-6170-48f3-beaa-87dcc86532d2

## Additional Context

In the video above, "Find all references" misses a few locations. I
captured that as a separate issue ( #5394 ) because since both features
rely on the same logic, fixing that would make this one work too... so
this PR is mostly about enabling "Find all references" rather than the
logic to actually find all references.

## 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.
- [ ] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.

---------

Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
github-merge-queue bot pushed a commit that referenced this issue Jul 4, 2024
# Description

## Problem

Resolves #5394

## Summary

Finds struct locations in return types and inside paths.

## Additional Context

Making it work for the return type was simple: the code to register it
is now done a bit earlier so it works in all cases where a type is
referred as the last segment in a Path.

Making it work when the type is in the middle of a Path (like in
`foo::Foo::new`) was a bit trickier: the existing Path lookup only cared
about (and registered) the result of the last segment. So now there's
code to register each segment in turn... but this is only done if
running in LSP mode. So in `foo::Foo::new`, `foo` is linked to a module
and `Foo` is linked to a struct. The existing code relied on the
`DependencyId` for this, but a "module" dependency didn't exist... to
avoid introducing new variants that are only used in this reference
tracking I instead created a new enum, `ReferenceId`.

## 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 Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant