Skip to content

Commit e5c8d4d

Browse files
committed
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 <[email protected]> TryBot-Result: Gopher Robot <[email protected]> gopls-CI: kokoro <[email protected]> Reviewed-by: Alan Donovan <[email protected]>
1 parent f4e8a71 commit e5c8d4d

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

gopls/internal/lsp/cache/load.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (s *snapshot) load(ctx context.Context, allowNetwork bool, scopes ...loadSc
9090
case viewLoadScope:
9191
// If we are outside of GOPATH, a module, or some other known
9292
// build system, don't load subdirectories.
93-
if !s.ValidBuildConfiguration() {
93+
if !s.validBuildConfiguration() {
9494
query = append(query, "./")
9595
} else {
9696
query = append(query, "./...")
@@ -359,7 +359,7 @@ func (s *snapshot) workspaceLayoutError(ctx context.Context) (error, []*source.D
359359
// If the snapshot does not have a valid build configuration, it may be
360360
// that the user has opened a directory that contains multiple modules.
361361
// Check for that an warn about it.
362-
if !s.ValidBuildConfiguration() {
362+
if !s.validBuildConfiguration() {
363363
var msg string
364364
if s.view.goversion >= 18 {
365365
msg = `gopls was not able to find modules in your workspace.

gopls/internal/lsp/cache/snapshot.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func (s *snapshot) Templates() map[span.URI]source.FileHandle {
321321
return tmpls
322322
}
323323

324-
func (s *snapshot) ValidBuildConfiguration() bool {
324+
func (s *snapshot) validBuildConfiguration() bool {
325325
// Since we only really understand the `go` command, if the user has a
326326
// different GOPACKAGESDRIVER, assume that their configuration is valid.
327327
if s.view.hasGopackagesDriver {
@@ -379,7 +379,7 @@ func (s *snapshot) workspaceMode() workspaceMode {
379379

380380
// If the view has an invalid configuration, don't build the workspace
381381
// module.
382-
validBuildConfiguration := s.ValidBuildConfiguration()
382+
validBuildConfiguration := s.validBuildConfiguration()
383383
if !validBuildConfiguration {
384384
return mode
385385
}
@@ -1448,8 +1448,8 @@ const adHocPackagesWarning = `You are outside of a module and outside of $GOPATH
14481448
If you are using modules, please open your editor to a directory in your module.
14491449
If you believe this warning is incorrect, please file an issue: https://github.com/golang/go/issues/new.`
14501450

1451-
func shouldShowAdHocPackagesWarning(snapshot source.Snapshot, active []*source.Metadata) string {
1452-
if !snapshot.ValidBuildConfiguration() {
1451+
func shouldShowAdHocPackagesWarning(snapshot *snapshot, active []*source.Metadata) string {
1452+
if !snapshot.validBuildConfiguration() {
14531453
for _, m := range active {
14541454
// A blank entry in DepsByImpPath
14551455
// indicates a missing dependency.
@@ -1559,7 +1559,7 @@ func (s *snapshot) reloadWorkspace(ctx context.Context) error {
15591559

15601560
// If the view's build configuration is invalid, we cannot reload by
15611561
// package path. Just reload the directory instead.
1562-
if !s.ValidBuildConfiguration() {
1562+
if !s.validBuildConfiguration() {
15631563
scopes = []loadScope{viewLoadScope("LOAD_INVALID_VIEW")}
15641564
}
15651565

gopls/internal/lsp/cache/view.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ func viewEnv(v *View) string {
424424
v.folder.Filename(),
425425
v.workingDir().Filename(),
426426
strings.TrimRight(v.workspaceInformation.goversionOutput, "\n"),
427-
v.snapshot.ValidBuildConfiguration(),
427+
v.snapshot.validBuildConfiguration(),
428428
buildFlags,
429429
v.goEnv,
430430
)

gopls/internal/lsp/source/view.go

-5
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ type Snapshot interface {
6363
// on behalf of this snapshot.
6464
BackgroundContext() context.Context
6565

66-
// ValidBuildConfiguration returns true if there is some error in the
67-
// user's workspace. In particular, if they are both outside of a module
68-
// and their GOPATH.
69-
ValidBuildConfiguration() bool
70-
7166
// A Snapshot is a caching implementation of FileSource whose
7267
// ReadFile method returns consistent information about the existence
7368
// and content of each file throughout its lifetime.

0 commit comments

Comments
 (0)