go/gopls/internal/regtest
Heschi Kreinick 2c115999a7 internal/lsp: use the go command to fix go.mod files
Modifying go.mod files directly leaves go.sum unchanged, and therefore
in need of updates later. Leaving work for the users to clean up isn't
ideal, so it'd be better to use the go command to make modifications.

Unfortunately, the go command has something of a mind of its own. The
most obvious problem is that using go get to add a new require adds a
// indirect comment to that new require, and there's no way to prevent
it. The only thing we can do is add the require first, then use go get
to do nothing but update the go.sum file.

The other inherent problem is that the go command operates on files as
they exist on disk, not the in-memory versions. As discussed, we issue
an error for this case. The alternative would be to work on temporary
files based on the in-memory contents, but that would be much larger
change, so I'd rather not at least right now.

To support Commands for quick fixes, add a new Command field to
source.SuggestedFix, and use it when forming the CodeAction response.

Fixes golang/go#38209.

Change-Id: I0c13ea39199368623e7494e222ba38587323d417
Reviewed-on: https://go-review.googlesource.com/c/tools/+/265981
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>
2020-10-28 22:47:54 +00:00
..
bench_test.go gopls/internal/regtest: always await InitialWorkspaceLoad 2020-09-29 16:13:45 +00:00
codelens_test.go internal/lsp: use the go command to fix go.mod files 2020-10-28 22:47:54 +00:00
completion_bench_test.go gopls/internal/regtest: always await InitialWorkspaceLoad 2020-09-29 16:13:45 +00:00
completion_test.go gopls/internal/regtest: add benchmarks for completions 2020-09-24 16:27:44 +00:00
configuration_test.go gopls/internal/regtest: always await InitialWorkspaceLoad 2020-09-29 16:13:45 +00:00
definition_test.go internal/lsp: fix hover for builtin error method (Error) 2020-10-05 18:50:03 +00:00
diagnostics_test.go internal/lsp: use the go command to fix go.mod files 2020-10-28 22:47:54 +00:00
doc.go gopls/integration/regtest: move regtests to the gopls module 2020-09-03 18:25:45 +00:00
env.go gopls/internal/regtest: simplify expectation return values 2020-09-16 12:40:19 +00:00
env_test.go gopls/integration/regtest: move regtests to the gopls module 2020-09-03 18:25:45 +00:00
expectation.go gopls/internal/regtest: add a failing test for swig 2020-10-13 01:55:53 +00:00
failures_test.go gopls: regtest to demonstrate gopls confused by //line directives 2020-10-21 12:08:33 +00:00
fix_test.go gopls/internal/regtest: always await InitialWorkspaceLoad 2020-09-29 16:13:45 +00:00
formatting_test.go gopls/internal/regtest: delete OpenFileWithContent 2020-10-16 23:30:35 +00:00
generate_test.go internal/lsp: fix go generate command for subdirs 2020-09-24 17:36:56 +00:00
imports_test.go gopls/internal/regtest: always await InitialWorkspaceLoad 2020-09-29 16:13:45 +00:00
link_test.go gopls/integration/regtest: move regtests to the gopls module 2020-09-03 18:25:45 +00:00
modfile_test.go internal/lsp: use the go command to fix go.mod files 2020-10-28 22:47:54 +00:00
references_test.go gopls/integration/regtest: move regtests to the gopls module 2020-09-03 18:25:45 +00:00
reg_test.go gopls/internal/regtest: allow cleanup to fail on windows 2020-09-30 20:10:28 +00:00
runner.go gopls: add regtest mode for experiments, like workspace module tests 2020-10-07 01:32:53 +00:00
shared_test.go gopls/integration/regtest: move regtests to the gopls module 2020-09-03 18:25:45 +00:00
stress_test.go gopls/integration/regtest: move regtests to the gopls module 2020-09-03 18:25:45 +00:00
symbol_helper_test.go gopls/integration/regtest: move regtests to the gopls module 2020-09-03 18:25:45 +00:00
symbol_test.go internal/lsp/source: add some additional symbol downranking 2020-09-16 12:25:06 +00:00
unix_test.go gopls/internal/regtest: simplify regtest EditorConfig 2020-09-16 12:02:33 +00:00
vendor_test.go gopls: add regtest mode for experiments, like workspace module tests 2020-10-07 01:32:53 +00:00
watch_test.go gopls/internal/regtest: add a test for switching from modules to GOPATH 2020-10-13 18:32:36 +00:00
workspace_test.go internal/lsp: handle major versions above v0/v1 in workspace module mode 2020-10-08 17:44:24 +00:00
wrappers.go gopls/internal/regtest: delete OpenFileWithContent 2020-10-16 23:30:35 +00:00