mirror of
https://github.com/golang/go
synced 2024-11-18 18:54:42 -07:00
internal/lsp: remove unnecessary "justOpened" field from goFile
Change-Id: I00a43ba8e2bc3ddc1f270113d8e1a49c801376a3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/196986 Reviewed-by: Ian Cottrell <iancottrell@google.com> Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
0f9bb8f614
commit
035fdb12d3
15
internal/lsp/cache/gofile.go
vendored
15
internal/lsp/cache/gofile.go
vendored
@ -26,11 +26,6 @@ type goFile struct {
|
||||
// It contains any packages with `go list` errors.
|
||||
missingImports map[packagePath]struct{}
|
||||
|
||||
// justOpened indicates that the file has just been opened.
|
||||
// We re-run go/packages.Load on just opened files to make sure
|
||||
// that we know about all of their packages.
|
||||
justOpened bool
|
||||
|
||||
imports []*ast.ImportSpec
|
||||
|
||||
cphs map[packageKey]*checkPackageHandle
|
||||
@ -138,16 +133,6 @@ func (f *goFile) isDirty(ctx context.Context, fh source.FileHandle) bool {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
|
||||
// If the the file has just been opened,
|
||||
// it may be part of more packages than we are aware of.
|
||||
//
|
||||
// Note: This must be the first case, otherwise we may not reset the value of f.justOpened.
|
||||
if f.justOpened {
|
||||
f.meta = make(map[packageID]*metadata)
|
||||
f.cphs = make(map[packageKey]*checkPackageHandle)
|
||||
f.justOpened = false
|
||||
return true
|
||||
}
|
||||
if len(f.meta) == 0 || len(f.cphs) == 0 {
|
||||
return true
|
||||
}
|
||||
|
5
internal/lsp/cache/session.go
vendored
5
internal/lsp/cache/session.go
vendored
@ -229,9 +229,10 @@ func (s *session) DidOpen(ctx context.Context, uri span.URI, kind source.FileKin
|
||||
log.Error(ctx, "not a Go file", nil, telemetry.File)
|
||||
return
|
||||
}
|
||||
// Mark file as open.
|
||||
// Force a reload of the package metadata by clearing the cached data.
|
||||
gof.mu.Lock()
|
||||
gof.justOpened = true
|
||||
gof.meta = make(map[packageID]*metadata)
|
||||
gof.cphs = make(map[packageKey]*checkPackageHandle)
|
||||
gof.mu.Unlock()
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,6 @@ func testLSP(t *testing.T, exporter packagestest.Exporter) {
|
||||
for filename, content := range data.Config.Overlay {
|
||||
session.SetOverlay(span.FileURI(filename), source.DetectLanguage("", filename), content)
|
||||
}
|
||||
|
||||
r := &runner{
|
||||
server: &Server{
|
||||
session: session,
|
||||
|
Loading…
Reference in New Issue
Block a user