gopls/internal/lsp/cache: unexport ValidBuildConfiguration
In general, the source package should not need to know about build
configurations. Remove this unused interface method, and unexport.
Change-Id: I91ba24e5bc2d172046ccaf3c46d2eb3f70e7bc42
Reviewed-on: https://go-review.googlesource.com/c/tools/+/495057
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
diff --git a/gopls/internal/lsp/cache/load.go b/gopls/internal/lsp/cache/load.go
index 521dc1e..111b074 100644
--- a/gopls/internal/lsp/cache/load.go
+++ b/gopls/internal/lsp/cache/load.go
@@ -90,7 +90,7 @@
case viewLoadScope:
// If we are outside of GOPATH, a module, or some other known
// build system, don't load subdirectories.
- if !s.ValidBuildConfiguration() {
+ if !s.validBuildConfiguration() {
query = append(query, "./")
} else {
query = append(query, "./...")
@@ -359,7 +359,7 @@
// If the snapshot does not have a valid build configuration, it may be
// that the user has opened a directory that contains multiple modules.
// Check for that an warn about it.
- if !s.ValidBuildConfiguration() {
+ if !s.validBuildConfiguration() {
var msg string
if s.view.goversion >= 18 {
msg = `gopls was not able to find modules in your workspace.
diff --git a/gopls/internal/lsp/cache/snapshot.go b/gopls/internal/lsp/cache/snapshot.go
index 45a32a1..7988a72 100644
--- a/gopls/internal/lsp/cache/snapshot.go
+++ b/gopls/internal/lsp/cache/snapshot.go
@@ -321,7 +321,7 @@
return tmpls
}
-func (s *snapshot) ValidBuildConfiguration() bool {
+func (s *snapshot) validBuildConfiguration() bool {
// Since we only really understand the `go` command, if the user has a
// different GOPACKAGESDRIVER, assume that their configuration is valid.
if s.view.hasGopackagesDriver {
@@ -379,7 +379,7 @@
// If the view has an invalid configuration, don't build the workspace
// module.
- validBuildConfiguration := s.ValidBuildConfiguration()
+ validBuildConfiguration := s.validBuildConfiguration()
if !validBuildConfiguration {
return mode
}
@@ -1448,8 +1448,8 @@
If you are using modules, please open your editor to a directory in your module.
If you believe this warning is incorrect, please file an issue: https://github.com/golang/go/issues/new.`
-func shouldShowAdHocPackagesWarning(snapshot source.Snapshot, active []*source.Metadata) string {
- if !snapshot.ValidBuildConfiguration() {
+func shouldShowAdHocPackagesWarning(snapshot *snapshot, active []*source.Metadata) string {
+ if !snapshot.validBuildConfiguration() {
for _, m := range active {
// A blank entry in DepsByImpPath
// indicates a missing dependency.
@@ -1559,7 +1559,7 @@
// If the view's build configuration is invalid, we cannot reload by
// package path. Just reload the directory instead.
- if !s.ValidBuildConfiguration() {
+ if !s.validBuildConfiguration() {
scopes = []loadScope{viewLoadScope("LOAD_INVALID_VIEW")}
}
diff --git a/gopls/internal/lsp/cache/view.go b/gopls/internal/lsp/cache/view.go
index db2c1dc..be2879d 100644
--- a/gopls/internal/lsp/cache/view.go
+++ b/gopls/internal/lsp/cache/view.go
@@ -424,7 +424,7 @@
v.folder.Filename(),
v.workingDir().Filename(),
strings.TrimRight(v.workspaceInformation.goversionOutput, "\n"),
- v.snapshot.ValidBuildConfiguration(),
+ v.snapshot.validBuildConfiguration(),
buildFlags,
v.goEnv,
)