go/internal/lsp/cache
Robert Findley e5f719fbe6 internal/lsp/source: consider test variants 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 rstambler@golang.org.

Fixes golang/go#47825

Co-authored-by: Rebecca Stambler <rstambler@golang.org>
Change-Id: I4693ec69b50ed4acd569cff87883769c1edf332b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/347563
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2021-09-08 14:51:59 +00:00
..
analysis.go internal/lsp: export and move some objects related to metadata 2021-08-15 15:51:49 +00:00
cache.go internal/lsp: export and move some objects related to metadata 2021-08-15 15:51:49 +00:00
check.go internal/lsp: export and move some objects related to metadata 2021-08-15 15:51:49 +00:00
error_test.go internal/lsp/cache: split up sourceDiagnostics 2021-03-02 02:05:13 +00:00
errors.go internal/lsp: export and move some objects related to metadata 2021-08-15 15:51:49 +00:00
imports.go internal/lsp/cache: fix panic in GOPATH mode 2021-01-07 18:21:03 +00:00
keys.go internal/lsp: decouple client and server debug 2020-06-11 13:49:48 +00:00
load.go internal/lsp/cache: fix flakiness of load progress reports 2021-08-17 14:56:21 +00:00
metadata.go internal/lsp: export and move some objects related to metadata 2021-08-15 15:51:49 +00:00
mod.go internal/lsp: fix support for SourceFixAll code actions 2021-03-24 23:51:27 +00:00
mod_tidy.go internal/lsp: remove unnecessary call to WorkspacePackages in mod tidy 2021-03-30 04:13:47 +00:00
os_darwin.go internal/lsp/cache: clarify an error message about mismatching casing 2021-08-03 17:18:10 +00:00
os_windows.go internal/lsp/cache: clarify an error message about mismatching casing 2021-08-03 17:18:10 +00:00
parse.go internal/lsp: export and move some objects related to metadata 2021-08-15 15:51:49 +00:00
parse_test.go internal/lsp/cache: trim more stuff in ParseExported mode 2021-05-11 17:48:41 +00:00
pkg.go internal/lsp: export and move some objects related to metadata 2021-08-15 15:51:49 +00:00
session.go internal/lsp: export and move some objects related to metadata 2021-08-15 15:51:49 +00:00
snapshot.go internal/lsp/source: consider test variants when finding pkg from pos 2021-09-08 14:51:59 +00:00
symbols.go internal/lsp: precompute workspace symbols 2021-08-09 20:20:17 +00:00
view.go internal/lsp: export and move some objects related to metadata 2021-08-15 15:51:49 +00:00
view_test.go internal/lsp: exclude the module cache from the workspace 2021-06-11 17:18:39 +00:00
workspace.go internal/lsp: start parsing go.work file like gopls.mod file 2021-06-24 04:20:31 +00:00
workspace_test.go internal/lsp: start parsing go.work file like gopls.mod file 2021-06-24 04:20:31 +00:00