1
0
mirror of https://github.com/golang/go synced 2024-11-18 10:54:40 -07:00

internal/lsp/cache: fix parseKey

The FileIdentity struct mixes information about the file itself
(filename, hash) with information about the LSP references to that file
(session ID, version). When we create a cache key using it, we only want
the former, as returned by the String method. Otherwise we split the
cache whenever those irrelevant fields are different.

We also use FileIdentity as an element of diagnosticsKey, but I believe
that use is appropriate.

Change-Id: I094e00d2700e05778da635effbb69d0ebcb6726e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/244020
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Heschi Kreinick 2020-07-21 14:17:53 -04:00
parent 72051f7961
commit 4d1d9acccf

View File

@ -24,7 +24,7 @@ import (
// parseKey uniquely identifies a parsed Go file.
type parseKey struct {
file source.FileIdentity
file string // FileIdentity.String()
mode source.ParseMode
}
@ -62,7 +62,7 @@ func (c *Cache) ParseGoHandle(ctx context.Context, fh source.FileHandle, mode so
func (c *Cache) parseGoHandle(ctx context.Context, fh source.FileHandle, mode source.ParseMode) *parseGoHandle {
key := parseKey{
file: fh.Identity(),
file: fh.Identity().String(),
mode: mode,
}
parseHandle := c.store.Bind(key, func(ctx context.Context, arg memoize.Arg) interface{} {