x/tools/gopls: eliminate dependence on "seen files"
findleyr opened this issue · 4 comments
Caveat: this is an abstract issue, but sufficiently fundamental to warrant independent tracking.
In two places inside gopls, there is a notion of "previously seen" files that affects gopls behavior:
- cache.View.knownFile, which is used to determine if a file is relevant to a given view
- cache.snapshot.FindFile (and anything that walks the snapshot.files set), which is used to filter to relevant or active files
These notions have no intrinsic definition: by construction they are path dependent. As such, they have been a source of historical and current bugs (for example, changing configuration can invalidate the set of known files, which leads to undefined behavior). They are also a source of test flakes, which is really just a manifestation of underlying bugginess.
We should replace these with well-defined notions, on a case by case basis. For example "is a file in the workspace directory", or "is this file in a loaded package, after loading completes".
Change https://go.dev/cl/459560 mentions this issue: gopls/internal/regtest: avoid race in TestSwitchFromGOPATHToModuleMode
Change https://go.dev/cl/468775 mentions this issue: gopls/internal/lsp/source: use metadata files for workspace symbols
Change https://go.dev/cl/525616 mentions this issue: gopls/internal/lsp/cache: simplify tracking of snapshot directories
Change https://go.dev/cl/551295 mentions this issue: gopls/internal/lsp/cache: switch to new bestViewForURI logic