internal/lsp/cache: be consistent about using snapshot.FileSet
Ideally we could at some point break the snapshot->view->session->cache
reverse traversal, but for now at least don't copy this pattern around
everywhere.
Change-Id: Ib144e6d322016f5b9563f21c56a0691c1a8ec97d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/309270
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>
diff --git a/internal/lsp/cache/analysis.go b/internal/lsp/cache/analysis.go
index 4f5f0bc..faf0306 100644
--- a/internal/lsp/cache/analysis.go
+++ b/internal/lsp/cache/analysis.go
@@ -257,7 +257,7 @@
// Run the analysis.
pass := &analysis.Pass{
Analyzer: analyzer,
- Fset: snapshot.view.session.cache.fset,
+ Fset: snapshot.FileSet(),
Files: syntax,
Pkg: pkg.GetTypes(),
TypesInfo: pkg.GetTypesInfo(),
diff --git a/internal/lsp/cache/errors.go b/internal/lsp/cache/errors.go
index 402f2ae..b866646 100644
--- a/internal/lsp/cache/errors.go
+++ b/internal/lsp/cache/errors.go
@@ -257,7 +257,7 @@
for _, fix := range diag.SuggestedFixes {
edits := make(map[span.URI][]protocol.TextEdit)
for _, e := range fix.TextEdits {
- spn, err := span.NewRange(snapshot.view.session.cache.fset, e.Pos, e.End).Span()
+ spn, err := span.NewRange(snapshot.FileSet(), e.Pos, e.End).Span()
if err != nil {
return nil, err
}
@@ -373,7 +373,7 @@
// Search file imports for the import that is causing the import cycle.
for _, imp := range cgf.File.Imports {
if imp.Path.Value == circImp {
- spn, err := span.NewRange(snapshot.view.session.cache.fset, imp.Pos(), imp.End()).Span()
+ spn, err := span.NewRange(snapshot.FileSet(), imp.Pos(), imp.End()).Span()
if err != nil {
return msg, span.Span{}, false
}
diff --git a/internal/lsp/cache/parse.go b/internal/lsp/cache/parse.go
index 3e61ece..f7cf1af 100644
--- a/internal/lsp/cache/parse.go
+++ b/internal/lsp/cache/parse.go
@@ -59,7 +59,7 @@
}
parseHandle := s.generation.Bind(key, func(ctx context.Context, arg memoize.Arg) interface{} {
snapshot := arg.(*snapshot)
- return parseGo(ctx, snapshot.view.session.cache.fset, fh, mode)
+ return parseGo(ctx, snapshot.FileSet(), fh, mode)
}, nil)
pgh := &parseGoHandle{
diff --git a/internal/lsp/cache/snapshot.go b/internal/lsp/cache/snapshot.go
index 21ca384..c741885 100644
--- a/internal/lsp/cache/snapshot.go
+++ b/internal/lsp/cache/snapshot.go
@@ -245,7 +245,7 @@
packages.NeedDeps |
packages.NeedTypesSizes |
packages.NeedModule,
- Fset: s.view.session.cache.fset,
+ Fset: s.FileSet(),
Overlay: s.buildOverlay(),
ParseFile: func(*token.FileSet, string, []byte) (*ast.File, error) {
panic("go/packages must not be used to parse files")