-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: gopls fails to resolve definition #47825
Comments
Thanks @matthiasgeihs for the report with the repro case. |
I added a little debug logging. It looks like a mismatch in parse modes; the check at https://cs.opensource.google/go/x/tools/+/master:internal/lsp/source/util.go;l=300;drc=f8cfadacc87adf3dd49cc1c165eb4f70931fc6fe is failing for both packages returned by |
Change https://golang.org/cl/347563 mentions this issue: |
@matthiasgeihs thanks very much for the report, especially with the repro.
This problem was actually that this particular package is imported as an intermediate test variant, which we had started filtering out. As a result, we couldn't find a package for the object position. CL 347563 contains a fix. |
Change https://golang.org/cl/348372 mentions this issue: |
…s when finding pkg from pos When resolving a position to a package we must consider all packages, including intermediate test variants. This manifests, for example, when jumping to definition in a package that is imported as a test variant (see golang/go#47825). For now, fix this by threading through an 'includeTestVariants' flag to PackagesForFile. This isn't pretty, but should be a trivially safe change: the only effect will be to increase the number of packages considered in FindPackageFromPos. Since we are discussing future changes to the API for querying packages from the snapshot, now did not seem like a good time to undertake significant refactoring. A regtest based on the original issue is included. This CL is joint with [email protected]. Fixes golang/go#47825 Co-authored-by: Rebecca Stambler <[email protected]> Change-Id: I4693ec69b50ed4acd569cff87883769c1edf332b Reviewed-on: https://go-review.googlesource.com/c/tools/+/347563 Trust: Robert Findley <[email protected]> Run-TryBot: Robert Findley <[email protected]> gopls-CI: kokoro <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]> (cherry picked from commit e5f719f) Reviewed-on: https://go-review.googlesource.com/c/tools/+/348372
What version of Go, VS Code & VS Code Go extension are you using?
go version
gopls -v version
code -v
Describe the bug
VSCode fails to resolve some type definitions when gopls is enabled.
The following error is printed on the
gopls
console output:Steps to reproduce the behavior:
gopls
is enabled.client/client_role_test.go
.ctest.RoleSetup
.Go to Definition
.Expected behavior: The editor opens the location of the definition.
Actual behavior: The editor shows
No definition for 'RoleSetup'
.Note: The type definition is resolved correctly when
gopls
is disabled.The text was updated successfully, but these errors were encountered: