go/internal/lsp
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 gopls, internal/lsp: support fillstruct for partially-filled structs 2020-11-30 20:22:45 +00:00
browser all: replace all usages of os/exec with golang.org/x/sys/execabs 2021-01-19 22:25:03 +00:00
cache internal/lsp: refactor go command error handling 2021-02-16 21:26:54 +00:00
cmd internal/lsp: switch to the new command API 2021-02-09 22:09:28 +00:00
command internal/lsp/command: stub out the ListKnownPackages and AddImport commands 2021-02-11 00:57:35 +00:00
debug internal/lsp: display current diagnostics in the debug server 2021-01-22 19:37:57 +00:00
diff all: add copyright notices to files that are missing them 2021-01-06 17:23:47 +00:00
fake internal/lsp: refactor go command error handling 2021-02-16 21:26:54 +00:00
fuzzy internal/lsp/fuzzy: fix return value on no match 2020-08-28 15:37:48 +00:00
helper all: add copyright notices to files that are missing them 2021-01-06 17:23:47 +00:00
lsprpc internal/lsp: display current diagnostics in the debug server 2021-01-22 19:37:57 +00:00
mod internal/lsp: apply go.sum fixes to all modules in multi-module module 2021-02-10 01:33:22 +00:00
protocol internal/lsp: eliminate funcs from commands, and refactor 2021-02-09 22:07:08 +00:00
snippet internal/lsp: offer type converted completion candidates 2020-11-30 20:04:59 +00:00
source internal/lsp: fix nil pointer in hover when (types.Object).Pkg() is nil 2021-02-16 20:53:32 +00:00
testdata internal/lsp/completion: fix untyped int type inference 2021-02-05 20:20:24 +00:00
tests internal/lsp: switch to the new command API 2021-02-09 22:09:28 +00:00
README.md internal/lsp: add READMEs that describe tests, how to run tests 2020-12-03 17:03:53 +00:00
call_hierarchy.go internal/lsp: release resources for call hierarchy file requests 2020-08-07 21:04:51 +00:00
code_action.go internal/lsp: apply go.sum fixes to all modules in multi-module module 2021-02-10 01:33:22 +00:00
code_lens.go internal/lsp: switch to the new command API 2021-02-09 22:09:28 +00:00
command.go internal/lsp: apply go.mod/sum changes via workspace edits 2021-02-11 05:13:29 +00:00
completion.go internal/lsp/cache: allow fixing multiple syntax errors 2021-02-05 19:47:01 +00:00
completion_test.go internal/lsp: update to latest version of LSP protocol 2021-02-02 11:32:59 +00:00
debounce.go internal/lsp: add experimental support for multi-phase diagnostics 2020-10-02 14:12:12 +00:00
debounce_test.go internal/lsp: delay longer in TestDebouncer 2020-10-30 20:03:00 +00:00
definition.go internal/lsp: handle nil pointer with import shortcut = link 2021-02-16 20:35:08 +00:00
diagnostics.go internal/lsp/cache: disable network for mod tidy diagnostics 2021-02-05 19:41:14 +00:00
folding_range.go all: add copyright notices to files that are missing them 2021-01-06 17:23:47 +00:00
format.go internal/lsp/cache: ref-count snapshots 2020-08-03 22:08:54 +00:00
general.go internal/lsp: update to latest version of LSP protocol 2021-02-02 11:32:59 +00:00
highlight.go internal/lsp/cache: ref-count snapshots 2020-08-03 22:08:54 +00:00
hover.go internal/lsp/cache: ref-count snapshots 2020-08-03 22:08:54 +00:00
implementation.go internal/lsp/cache: ref-count snapshots 2020-08-03 22:08:54 +00:00
link.go internal/lsp: add ?utm_source=gopls to links to pkg.go.dev 2020-11-16 00:15:58 +00:00
lsp_test.go internal/lsp: switch to the new command API 2021-02-09 22:09:28 +00:00
progress.go internal/lsp: update to latest version of LSP protocol 2021-02-02 11:32:59 +00:00
progress_test.go internal/lsp: improvements for command messages 2020-08-21 20:07:30 +00:00
references.go internal/lsp/cache: ref-count snapshots 2020-08-03 22:08:54 +00:00
rename.go internal/lsp/source: make it an error to rename embedded fields 2021-01-26 13:52:46 +00:00
reset_golden.sh
semantic.go internal/lsp: update to latest version of LSP protocol 2021-02-02 11:32:59 +00:00
server.go internal/lsp: avoid panic during interface assertion 2021-01-02 18:51:54 +00:00
server_gen.go internal/lsp: update to latest version of LSP protocol 2021-02-02 11:32:59 +00:00
signature_help.go internal/lsp: update to latest version of LSP protocol 2021-02-02 11:32:59 +00:00
symbols.go internal/lsp/cache: ref-count snapshots 2020-08-03 22:08:54 +00:00
text_synchronization.go internal/lsp: update to latest version of LSP protocol 2021-02-02 11:32:59 +00:00
workspace.go internal/lsp: fix capability registration for semantic tokens 2020-11-16 18:11:12 +00:00
workspace_symbol.go internal/lsp/source: add a new symbolStyle configuration option 2020-06-26 17:13:37 +00:00

README.md

lsp

internal/lsp provides much of the Language Server Protocol (lsp) implementation for gopls.

Documentation for users and contributors can be found in the gopls/doc directory.