aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Viernau <frank_viernau@epam.com>2023-02-22 21:48:57 +0000
committerGopher Robot <gobot@golang.org>2023-02-22 21:51:18 +0000
commit3ec30bd95cd143796a8b51514c85d5667d261333 (patch)
tree2531f53583157ead024af0d17737e289e0dc2f65
parent25d2519c869614b0d15632ad5d03f656e267eef1 (diff)
downloadgolang-x-tools-3ec30bd95cd143796a8b51514c85d5667d261333.tar.gz
gopls/internal/lsp/cache: request EmbedFiles from go/packages
Gopls attempts to diagnose incorrect embed patterns. The logic to do so relies on 'go list' to actually resolve those patterns and to propagate an error in case the pattern is incorrect, see also [1]. Gopls explicitly specifies the needed JSON fields towards 'go list -json' which internally skips evaluation steps for unneeded fields. Currently, the embed patterns are always evaluated but there is plans to only run pattern evaluation if needed [2]. So, explicitly ask for EmbedFiles to prepare for [2]. [1]: https://github.com/golang/tools/blob/193023cca0b707b4d668e5d332649cba285e99f7/gopls/internal/regtest/misc/embed_test.go#L26-L40 [2]: https://github.com/golang/go/pull/58522 Change-Id: I615cd5076659f192d884504ab735ce77b6e0e129 GitHub-Last-Rev: 9c1addbf9f26233dbe31c08fd98335bfd6aa1062 GitHub-Pull-Request: golang/tools#428 Reviewed-on: https://go-review.googlesource.com/c/tools/+/470157 Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
-rw-r--r--gopls/internal/lsp/cache/snapshot.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/gopls/internal/lsp/cache/snapshot.go b/gopls/internal/lsp/cache/snapshot.go
index ab4255655..d0885f07a 100644
--- a/gopls/internal/lsp/cache/snapshot.go
+++ b/gopls/internal/lsp/cache/snapshot.go
@@ -385,6 +385,7 @@ func (s *snapshot) config(ctx context.Context, inv *gocommand.Invocation) *packa
packages.NeedDeps |
packages.NeedTypesSizes |
packages.NeedModule |
+ packages.NeedEmbedFiles |
packages.LoadMode(packagesinternal.DepsErrors) |
packages.LoadMode(packagesinternal.ForTest),
Fset: nil, // we do our own parsing