internal/lsp/cache: don't build symbol info for non-Go files

Our symbol query only searches Go files, so there is no point to
building (broken) symbol information for non-Go files. Doing so
introduces a lot more symbol handles that need to be tracked and walked.

Change-Id: I96dd62766d079805fcb1d16eb361adfc0c31eea1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/415199
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Rob Findley 2022-06-30 10:50:45 -04:00 committed by Robert Findley
parent b84d509d6f
commit 1a196f0497
1 changed files with 4 additions and 0 deletions

View File

@ -1010,6 +1010,10 @@ func (s *snapshot) Symbols(ctx context.Context) map[span.URI][]source.Symbol {
result = make(map[span.URI][]source.Symbol)
)
s.files.Range(func(uri span.URI, f source.VersionedFileHandle) {
if s.View().FileKind(f) != source.Go {
return // workspace symbols currently supports only Go files.
}
// TODO(adonovan): upgrade errgroup and use group.SetLimit(nprocs).
iolimit <- struct{}{} // acquire token
group.Go(func() error {