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

[DSLX:LS] Add support for prepareRename and rename #1640

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

cdleary
Copy link
Collaborator

@cdleary cdleary commented Sep 28, 2024

Works for intra-function and intra-module definitions.

Support is not present for cross-workspace renames yet.

image

@cdleary cdleary force-pushed the cdleary/2024-09-26-lsp-prepare-rename branch from bbe3eb5 to 424a5f1 Compare September 28, 2024 05:22
@cdleary cdleary changed the title [DSLX:LS] Add support for textDocument/prepareRename [DSLX:LS] Add support for prepareRename and rename Sep 28, 2024
@ericastor
Copy link
Collaborator

Mind syncing & rerunning? Looks like CI failed...

@cdleary cdleary force-pushed the cdleary/2024-09-26-lsp-prepare-rename branch 2 times, most recently from bac0775 to 4c84049 Compare October 1, 2024 03:30
Module-scoped renames for non-pub members.
@cdleary cdleary force-pushed the cdleary/2024-09-26-lsp-prepare-rename branch from 4c84049 to acac707 Compare October 1, 2024 04:10
@cdleary
Copy link
Collaborator Author

cdleary commented Oct 1, 2024

Mind syncing & rerunning? Looks like CI failed...

Yeah, was really change related, had trouble seeing it since baseline was red. Setting parent link on module-top AST nodes was hazardous for some reason I don't fully understand so I made a simpler change. PTAL, thanks.

xls/dslx/lsp/find_definition.cc Outdated Show resolved Hide resolved
@@ -41,7 +41,8 @@ namespace xls::dslx {
// colon-reference to a construct in another module will return nullopt.
std::optional<Span> FindDefinition(const Module& m, const Pos& selected,
const TypeInfo& type_info,
ImportData& import_data);
ImportData& import_data,
const NameDef** name_def_out = nullptr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than returning name_def_out through an argument, it seems easier to have this be std::optional<NameDef*> FindDefinition(...) and have existing usages update to get the span from the NameDef.

What do you think? Is it really annoying to update the usages?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, done, PTAL.

@grebe grebe self-assigned this Oct 4, 2024
@cdleary cdleary requested a review from grebe October 5, 2024 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants