1
0
mirror of https://github.com/golang/go synced 2024-11-18 20:04:52 -07:00
go/internal/lsp/cache
Heschi Kreinick 76a3b8da50 internal/memoize: propagate cancellation
If a user is typing fast, they will quickly invalidate many snapshots.
We don't want to stack up a bunch of stale type check and analysis
operations, so we should propagate cancellation through the cache.

Handles are long-lived, so we may cancel an operation only to
restart it again later. Also, there may be multiple operations waiting on
the same computation, and just because one is cancelled doesn't mean we
should necessarily stop. The easiest way to support all that was to add
an explicit state to each handle, and track the number of waiters.

See the code for more details on Handle life cycles.

As far as I can tell, the rest of gopls is prepared for this behavior.
I added an explicit check to the type checking code, where I was worried
it might get overly confused. But long-term it would probably be good to
return an error from Get.

Change-Id: I3ea6e141b52b94300a41248d3f2e039b023709d0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/206879
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-11-12 23:22:37 +00:00
..
analysis.go internal/lsp/cache: handle a nil pointer exception in analysis 2019-11-08 17:37:09 +00:00
builtin.go internal/lsp: address staticcheck warnings 2019-10-04 02:16:23 +00:00
cache.go internal/lsp: use options hooks to install diff driver 2019-10-11 16:38:31 +00:00
check.go internal/memoize: propagate cancellation 2019-11-12 23:22:37 +00:00
error_test.go internal/lsp: refactor error handling code in type-checking 2019-10-21 18:57:46 +00:00
errors.go internal/lsp/cache: avoid returning errors when building source.Errors 2019-11-12 00:54:22 +00:00
external.go internal/lsp: address staticcheck warnings 2019-10-04 02:16:23 +00:00
file.go internal/lsp: modify approach to watching changed files 2019-10-22 21:33:45 +00:00
gofile.go internal/lsp: call load in (*session).NewView 2019-11-07 23:34:59 +00:00
load.go internal/lsp/cache: have NewView create view even if load all packages fails 2019-11-11 18:23:52 +00:00
parse.go internal/lsp: stop caching diagnostics on the package 2019-10-24 22:03:59 +00:00
pkg.go internal/lsp/source: attach Package to completions when available 2019-11-05 20:21:09 +00:00
session.go internal/lsp: make View.SetOptions save and useful 2019-11-12 16:15:35 +00:00
snapshot.go internal/lsp: support implementations requests for implementations in other packages 2019-11-12 18:49:59 +00:00
view.go internal/lsp: make View.SetOptions save and useful 2019-11-12 16:15:35 +00:00
watcher.go internal/lsp: modify approach to watching changed files 2019-10-22 21:33:45 +00:00