go/internal/lsp/cache
Heschi Kreinick 1e7abacf3b internal/lsp: refactor go command error handling
Our handling of go command errors was cobbled together, leading to
unexpected gaps and duplication. Refactor it to be more coherent.

Our goal is to turn every go command error into a diagnostic in the
relevant location. The errors don't contain error positions, so we have
to guess where they belong using the module names mentioned in the
error. If we can't find any reference to those modules, we are forced to
add diagnostics to all go.mod files.

I may have destroyed the intent of TestMultiModule_OneBrokenModule but
I'm not sure what to do about it.

Some cleanup along the way:
- Stop parsing modfile.Parse error text: it returns structured errors
and we can just use them.
- Return CriticalErrors from awaitLoadedAllErrors, and do error
extraction lower in the stack. This prevents a ridiculous situation
where initialize formed a CriticalError, then awaitLoadedAllErrors
returned just its MainError, and then GetCriticalError parsed out
a new CriticalError from the MainError we got from a CriticalError.
- In initialize, return modDiagnostics even if load succeeds: we are
missing packages and should not silently fail, I think?
- During testing I tripped over ApplyQuickFixes' willingness to not
actually do anything, so I made that an error.

Fixes golang/go#44132.
I may also have fixed golang/go#44204 but I haven't checked.

Change-Id: Ibf819d0f044d4f99795978a28b18915893e50c88
Reviewed-on: https://go-review.googlesource.com/c/tools/+/291192
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-02-16 21:26:54 +00:00
..
analysis.go internal/lsp/cache: disable network for mod tidy diagnostics 2021-02-05 19:41:14 +00:00
cache.go internal/lsp/cache: compare file size when invalidating file cache 2021-01-12 21:35:00 +00:00
check.go internal/lsp: switch to the new command API 2021-02-09 22:09:28 +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: remove redundant fields/code after source.Error deletion 2021-02-02 23:37:55 +00:00
imports.go internal/lsp/cache: fix panic in GOPATH mode 2021-01-07 18:21:03 +00:00
keys.go internal/lsp: decouple client and server debug 2020-06-11 13:49:48 +00:00
load.go internal/lsp/cache: disable network for mod tidy diagnostics 2021-02-05 19:41:14 +00:00
mod.go internal/lsp: refactor go command error handling 2021-02-16 21:26:54 +00:00
mod_tidy.go internal/lsp: refactor go command error handling 2021-02-16 21:26:54 +00:00
os_darwin.go internal/lsp: add a mutex around the view's options 2020-04-02 16:41:49 +00:00
os_windows.go internal/lsp/cache: validate workspace path case 2020-03-27 19:55:53 +00:00
parse.go internal/lsp/cache: allow fixing multiple syntax errors 2021-02-05 19:47:01 +00:00
parse_test.go internal/lsp/cache: trim ellipsis array literals 2020-08-12 23:16:40 +00:00
pkg.go internal/lsp: remove the source.Error type 2021-02-02 20:40:51 +00:00
session.go internal/lsp: always return file handles for nonexistent files 2021-02-12 21:26:46 +00:00
snapshot.go internal/lsp: refactor go command error handling 2021-02-16 21:26:54 +00:00
view.go internal/lsp: refactor go command error handling 2021-02-16 21:26:54 +00:00
view_test.go internal/lsp: refactor go command error handling 2021-02-16 21:26:54 +00:00
workspace.go internal/lsp/cache: only reload the workspace on saved changes 2020-12-23 22:53:30 +00:00
workspace_test.go internal/lsp/cache: compare file size when invalidating file cache 2021-01-12 21:35:00 +00:00