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: fillstruct heuristic fails to look beneath current point, or in other files #68224

Open
adonovan opened this issue Jun 27, 2024 · 2 comments
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

@adonovan
Copy link
Member

The fillstruct code action looks for declarations in the current file, before the current point, as candidates for the initializers of each missing field. That seems doubly arbitrary: package-level declarations in other files should be candidates too, as should declarations beneath the current point.

@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 Jun 27, 2024
@gopherbot gopherbot added this to the Unreleased milestone Jun 27, 2024
@findleyr findleyr modified the milestones: Unreleased, gopls/backlog Jun 28, 2024
@findleyr
Copy link
Member

Skimming the logic, it appears that fillstruct does a syntactic analysis to find candidate identifiers, but then only uses their name.

I don't know why all of this logic couldn't just be replaced by a simple scope traversal.

We could also traverse the package scopes of direct imports, though that is less likely to be what the user wants, IMO.

@findleyr
Copy link
Member

CC @madelinekalil, who has been looking at the fillstruct code action recently.

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

3 participants