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: consider multiplexing navigation across all Views (with partial results?) #65755

Open
findleyr opened this issue Feb 16, 2024 · 1 comment
Labels
gopls/metadata Issues related to metadata loading in gopls 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

This is a follow up issue to #29202 and #57979.

In those issues we added dynamic support for working on multiple modules or GOOS/GOARCH combinations simultaneously. While this may simplify workspace configuration, it does mean that certain navigation queries may be confusing, because most operations in gopls still pick exactly one build from which to execute.

The simplest example of this is cross-references requests: if the user is in a file, and finds references to e.g. fmt.Sprintf, that references query will only return results for the default build of that file. This can be confusing if e.g. finding references to a standard library symbol from foo.go returns different results than finding references from e.g. foo_windows.go.

I was intentionally trying to tread carefully with respect to the performance implications of tracking multiple builds: we don't want to do twice the work when a user may typically be working on one build at a time. For example, consider the case of a symbol in the shared package graph of the default build and a GOOS=windows build. In the common case, the set of references will be identical across both builds, and so doing twice the work is not desirable. Additionally, for the case of multiple-modules, this problem can usually be mitigated by adding a go.work file, if desired.

However, this is very liable to be confusing. It would be relatively straightforward to multiplex queries across all builds containing a file, and merge the results. We should consider doing so, based on feedback. Perhaps there's something else we can do to solve this problem -- I wish the user had the ability to differentiate "fast references" from "all possible references".

One solution may be to use the partial results support that most of these operations include. We can return an initial set of results once we've processed the default build, and proceed with additional builds. However, this would the first time we've done something like this, so it requires careful testing across LSP clients.

References is one operation illustrating the problem. The same applies to definition, implementations, call hierarchy, etc. -- anything related to navigation. I think this is less important for things like hover, signatureHelp, or completion.

CC @adonovan

@findleyr findleyr added the gopls/metadata Issues related to metadata loading in gopls label Feb 16, 2024
@findleyr findleyr added this to the gopls/v0.16.0 milestone Feb 16, 2024
@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 Feb 16, 2024
@findleyr
Copy link
Contributor Author

Argh, I forgot (again) that VS Code still does not support partial results (microsoft/vscode#105870).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/metadata Issues related to metadata loading in gopls 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

2 participants