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

x/tools/gopls: improvements to package renaming #56184

Open
5 tasks
findleyr opened this issue Oct 12, 2022 · 5 comments
Open
5 tasks

x/tools/gopls: improvements to package renaming #56184

findleyr opened this issue Oct 12, 2022 · 5 comments
Assignees
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Contributor

findleyr commented Oct 12, 2022

This issue tracks improvements to package renaming that we are aiming to land in gopls@v0.11.0, namely:

  • Add a test for the case when the renaming package's path contains "internal" as a segment.
  • Allow edit to the whole package path not just only the last segment of the package path
  • Reject renaming if the renamed subpackages don't belong to the same module with the renaming package
  • Check the go.mod files in the workspace to see if any replace directives need to be fixed if the renaming affects the locations of any go.mod files
  • Allow renaming to arbitrary locations, by changing the PrepareRename behavior to prompt with the full package path.
@findleyr findleyr added this to the gopls/v0.11.0 milestone Oct 12, 2022
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Oct 12, 2022
@bcmills
Copy link
Member

bcmills commented Oct 13, 2022

Reject renaming if the renamed subpackages don't belong to the same module with the renaming package

Hmm. I think it should be fine to rename across modules as long as both modules are in the workspace..?

@uh-zz
Copy link

uh-zz commented Nov 1, 2022

I was looking forward to this feature!

I tried package rename in the following environment and it seems that the renamed file is newly created and the original file is deleted.
Is this expected behavior?

Visual Studio Code v1.72.2
golang.org/x/tools/gopls v0.10.0

@findleyr
Copy link
Contributor Author

findleyr commented Nov 1, 2022

@uh-zz yes, this is how VS Code handles the RenameFile operation. Unfortunately, I believe this is out of our control.

@gopherbot
Copy link

gopherbot commented Nov 15, 2022

Change https://go.dev/cl/450556 mentions this issue: gopls/internal/regtest: add a test for the case when the renaming package's path contains "internal" as a segment

@gopherbot
Copy link

gopherbot commented Nov 15, 2022

Change https://go.dev/cl/450557 mentions this issue: gopls/internal/lsp: change PrepareRename behavior to prompt with the full package path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants