Граф коммитов

5574 Коммитов

Автор SHA1 Сообщение Дата
Rob Findley 43ebab892c gopls/doc: fix section rewriting
Sections were being iteratively replaced in the original doc, rather
than an incrementally updated doc.

Change-Id: Ie49058ecc109e3f99babe24f02ee9c742915cd8d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/258567
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-10-01 10:43:56 +00:00
Rebecca Stambler e57f6d466a internal/lsp: move hasValidBuildConfiguration into the snapshot
Update hasValidBuildConfiguration as modules are created and deleted.

Change-Id: I9196611225d42a87ea5790c564bc9ac1ea1871f1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/257968
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-09-30 21:31:15 +00:00
Rebecca Stambler 2e5f0cfadf internal/lsp: remove all but one use of the view's modURI field
The view reinitialization logic appears to be broken, and so needs one
remaining use of the modURI, which be fixed in a follow-up. Every other
use of view.modURI is removed.

Updates golang/go#32394

Change-Id: Ic051ed848c30e6981d42a576fb35f40efbeb17a6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/257417
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Trust: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-09-30 20:43:29 +00:00
Rob Findley a6f32d173b gopls/internal/regtest: allow cleanup to fail on windows
Due to Windows' default file locking and the fact that regtests shell
out to the go command, cleanup sometimes fails.

This is causing trybot flakes, increasingly as of late. Since the
tempdir will eventually be cleaned up on the trybots anyway, don't fail
on windows.

For golang/go#38490

Change-Id: I136d97143baba1d98777db51daa062cf0e42e33e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/258315
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-09-30 20:10:28 +00:00
Danish Dua a44386fadb internal/lsp/source/completion: use c.matcher for comments
This change adds calls to c.matcher.score for commment completion so
comments match the prefix (or fuzzy match depending on user settings)
and don't end up giving the user too many irrelevant suggestions.

Change-Id: Ie660f82c491c17d52e68e781a812bf8053e501f8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/258322
Trust: Danish Dua <danishdua@google.com>
Run-TryBot: Danish Dua <danishdua@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-09-30 19:40:55 +00:00
Rebecca Stambler 66e72d03b2 internal/lsp: print the go version only once the view is created
Printing the Go version without the session's go command runner means
that we may not find the right Go version. Also, panicking when we
cannot find a go command is not useful to the user--show the error as a
view initialization error instead.

Fixes golang/go#41701

Change-Id: I0e0753da9795b1c78331db1faecd27c2bfcee9b4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/258312
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2020-09-30 16:38:20 +00:00
Peter Weinbergr c8c0a1c017 internal/lsp/semantic.go: add the skeleton for supporting semantic tokens
This Cl adds all the support for producing semantic tokens other than
generating them. That includes new stubs for LSP, a new option for
the user to choose semantic tokens, and the skeleton for producing
semantic tokens, except that 0 semantic tokens are produced.

vscode 1.49.1 (the current version) does not ask for semantic tokens;
vscode-insiders does.

Change-Id: Iceb8fff974deb9283281319bb5878271c3d3170d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/257578
Run-TryBot: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Trust: Peter Weinberger <pjw@google.com>
2020-09-30 14:30:06 +00:00
Rebecca Stambler bf155c11ec internal/lsp: use published diagnostics instead of reports in lsp_test
Relying on the reports returned by (*Server).diagnose adds a constraint
on the signature of that function. Change to using the diagnostics
cached on the server to determine what gopls published to the client.

Change-Id: I49c1cddcf7db81a79e154a9935016b2ef2e5d69c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/257378
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2020-09-29 22:30:13 +00:00
Danish Dua bce87a7896 internal/lsp/source/completion: remove unused contexts
This change removes contexts from functions that don't use them. Passing
down context unnecessarily leads to us having to propagate them
everywhere.

Change-Id: I1723721faf4f487b6cc92b9daef3f23747d9cbc1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/258285
Trust: Danish Dua <danishdua@google.com>
Run-TryBot: Danish Dua <danishdua@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-09-29 21:00:17 +00:00
Danish Dua c43c25c95a internal/lsp/source: run deep completions before unimported completions
Unimported completions are expensive and can use up a large portion of
completion budget just to find initial deep search candidates. This
change moves these expensive operations which search through the module
cache to after normal deep completions so we search through more useful
candidates first.

Fixes golang/go#41434
Fixes golang/go#41665

Change-Id: I6f3963f8c65c1a97833a35738d2e96420de2f6ee
Reviewed-on: https://go-review.googlesource.com/c/tools/+/257974
Run-TryBot: Danish Dua <danishdua@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Trust: Danish Dua <danishdua@google.com>
2020-09-29 20:25:52 +00:00
Rebecca Stambler f1e51e6b94 internal/lsp: stop using modURI as much as possible
This change switches over load and RunProcessEnvFunc to use the
snapshot's modules instead of the view's modURI. These do not seem to
have been the racy parts of CL 257417.

Change-Id: I317a350fc4b0c62d77858455a0e2e61148804ecd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/257969
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-09-29 19:10:02 +00:00
Dmitri Shuralyov fc8742f947 cmd/bundle: expand test coverage to all modes
As of CL 189818, bundle has been updated to use the go/packages API to
load packages. That API supports module mode and legacy GOPATH mode.
Update the test to provide coverage for all modes.

Updates golang/go#24661.

Change-Id: Ied6196f7317b9b0289faf80dbfe9815e9b98b55d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/255053
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2020-09-29 17:50:58 +00:00
Rob Findley 5272f303b6 gopls: fix various staticcheck errors
Do a pass of unused code cleanup and other staticcheck errors.

Change-Id: Iaf5d27c4f5405d4cce3e48fa06a5d46ec757de40
Reviewed-on: https://go-review.googlesource.com/c/tools/+/257965
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
2020-09-29 17:30:36 +00:00
Filippo Valsorda ffa3839b1b cmd/bundle: use caller's module version via go/packages
Also, remove obsolete -underscore option.

Fixes golang/go#32031
Updates golang/go#24661

Change-Id: I47940a7ccfaf82a042eadc76f47304fc1dd8cbdd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/189818
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-09-29 17:13:17 +00:00
Rob Findley d7fc70abf5 gopls/internal/regtest: always await InitialWorkspaceLoad
There's very little reason not to always await IWL, and none of our
tests actually need to be able to execute before it completes.

Await IWL before running the test func.

Change-Id: Ia0626aa4e4c6cfa89dc5d03075b6bd797574a8dc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/258078
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Trust: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-09-29 16:13:45 +00:00
Rebecca Stambler a0ef9b62de internal/lsp: prepare for deletion of view.modURI
Splitting this CL out of CL 257417 to minimize the number of changes.
A few of the view's methods are moved to the snapshot, as they will
soon rely on the snapshot's modules field. Some dead code is also
deleted.

We now populate the snapshot's modules field even when
ExperimentalWorkspaceModule is not true, but we stop looking for modules
after searching the view's root.

Change-Id: Id0068ec10fafcfa6f7694dfcb8aaee8cb025078f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/257961
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-09-28 20:19:43 +00:00
Rob Findley 19e0367891 internal/lsp/cache: use gopls.mod for the workspace module if it exists
When building the workspace module, prefer a gopls.mod file located at
the root of the view if it exists.

Also do some minor documenting/cleanup along the way.

For golang/go#32394

Change-Id: If87729a766d37e6c834fefe40cfb47b67a36a60c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256582
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Trust: Robert Findley <rfindley@google.com>
2020-09-28 18:20:47 +00:00
Heschi Kreinick 50ab9675f5 internal/lsp/source: add additional generated docs
Enable documentation for Debugging options, code lenses, and LSP
commands.

See the comment in loadCommands; reading comments off a composite
literal is annoying. If the documentation were available at runtime this
would be much easier, and we should probably switch to that at the first
sign of trouble.

Fixes golang/go#33544.

Change-Id: I503b62aa2fc4a993f5978c449088db54fc79f7de
Reviewed-on: https://go-review.googlesource.com/c/tools/+/257737
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-09-28 17:29:33 +00:00
Rob Findley 42b62fc938 gopls/internal/regtest: fix data race when printing logs
Lock around log access in regtests. This flake was relatively rare in
regtests because of the serial nature of our jsonrpc2 implementation,
but was nonetheless racy.

Fixes golang/go#41653

Change-Id: I08674f42b05624a69d33885c2232c9e31866375b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/257957
Trust: Rebecca Stambler <rstambler@golang.org>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-09-28 11:28:10 +00:00
Rebecca Stambler 5d1fdd8fa3 internal/lsp: allow multiple go.mod files in a view
This change allows a view to have multiple go.mod files associated
with it. This doesn't actually make any changes in internal/lsp/cache
with regards to the view's modURI, but it does do the necessary plumbing
in the client packages.

The next CL will delete modURI.

Updates golang/go#32394

Change-Id: I2312efd69c364aed4244ee3769679885a1ebc7e4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256941
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-09-25 19:12:24 +00:00
Heschi Kreinick e8435508c6 internal/lsp: run marker tests in multi-module mode
Multi-module mode works rather differently than module mode, so ideally
we should have good test coverage for it. We can get a lot for a little
by running the marker tests as a module in a multi-module workspace. To
do that, we can move everything one directory lower, and use the
original directory as the root of the workspace.

The mechanics of setting it up are a little distasteful but not too bad.
We prepend a directory to all the paths in the packagestest.Module, and
after Export, move the created go.mod down into that directory. The only
other change is to find the golden files in the right place.

Command line tests use URIs everywhere, and it was too annoying to fix
them, so I didn't bother. Unimported completion tests fail and are
skipped for the moment.

Change-Id: I5a15156ca4c357ca668bfee05deb9493203e43a1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256821
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-09-25 18:05:33 +00:00
Rebecca Stambler 4c77dbd9e5 internal/lsp: fix race condition caused by config in `go mod tidy`
Reusing the config causes a race condition because it may be modified.
Get a new config in the bound function instead.
See the logs here:
https://storage.googleapis.com/go-build-log/23cc16cd/linux-amd64-race_343e911a.log.

Change-Id: Iaab43631740e43ba97cd70f7cd8a3bbaa91c26c9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/257206
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-09-25 16:30:29 +00:00
Ainar Garipov 34b80a0a46 gopls/doc: update and expand the nvim documentation
Change-Id: If7df2c5b0cefb73e96641187bcd721962d72cb4d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/257437
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Trust: Rebecca Stambler <rstambler@golang.org>
Trust: Robert Findley <rfindley@google.com>
2020-09-25 15:01:35 +00:00
Rebecca Stambler 0eae6ac92e internal/lsp: add a test for gc annotation details code lens
This change adds a test to check the functionality of the GC details
code lens, including the behavior of toggling it on and off. This
exposed a Windows bug that was mentioned on Slack, which can be fixed by
adjusting the URI.

I also refactored a bit of the code to use a JSON decoder, which
simplifies things a little bit.

Change-Id: I7737107cf020fa35bca245485a3b1a1416920fd2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256940
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
2020-09-25 14:57:16 +00:00
Danish Dua 8d73f17870 internal/lsp: move package selection to before type checking
This change moves package selection to before type checking so we don't
unnecessarily type-check both variants of a package. As a result, exec
time and memory usage for features making calls to GetParsedFile are cut
by half since we only type check either the narrowest or the widest
package.

Change-Id: Ifd076f8c38e33de2bd3509fe17feafccd59d7419
Reviewed-on: https://go-review.googlesource.com/c/tools/+/257240
Run-TryBot: Danish Dua <danishdua@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Danish Dua <danishdua@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-09-24 22:42:22 +00:00
Rebecca Stambler 8a9a89368b internal/lsp/cache: don't set tempModFile is view's modURI is empty
This fixes panics caused by us thinking that we should use tempModFile
without a go.mod in the view. This code will likely go away after
view.modURI is deleted.

Change-Id: I77a9c9f62bcac27cafa69eb970e004dd58d29d07
Reviewed-on: https://go-review.googlesource.com/c/tools/+/257201
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-09-24 20:59:11 +00:00
Rebecca Stambler 0f1c53950d internal/lsp: show orphaned file warnings as diagnostics
Show message warnings are annoying to users. Instead, show a diagnostic
for orphaned files. Right now, it will always be there (instead of on
first open). Not sure if users will find this annoying or helpful.

Fixes golang/go#31668

Change-Id: I5051072b00fee9018d447585fdd9cdfe9df7107a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256977
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
2020-09-24 18:28:24 +00:00
Heschi Kreinick 7b6ac5b934 internal/lsp/cache: slightly more useful comment
Explain why we're ignoring errors, not just that we are.

Change-Id: I6cbb4945ef6066180953dcaba6f561843d7f20a1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256820
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-09-24 18:10:31 +00:00
Rebecca Stambler 24570c0594 internal/lsp: handle initial workspace load failure per module
This CL adds diagnostics to the go.mod file if one of the modules in
the workspace is invalid and causes the initial workspace load to fail.
When the module is fixed, the initial workspace load will be retried.

This CL also introduces the *source.ErrorList error type, which will be
useful in the future as a way of producing diagnostics out of errors.

Updates golang/go#32394

Change-Id: Ib8860a4f16c1983b8512f75e26354512d5a9a86d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/254753
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2020-09-24 18:05:18 +00:00
Rebecca Stambler 04afef382b internal/lsp: don't search for workspace modules by default
This may be expensive, and we don't want to do it if the results will
be unused.

Updates golang/go#41558

Change-Id: I0c01a80f4fc459e1cc189934ad23ab443e5ea2a5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/257137
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2020-09-24 17:47:22 +00:00
Rob Findley 7bb30d1408 internal/lsp: fix go generate command for subdirs
The go generate command was not honoring its dir argument, instead just
running in the workspace root.

Fixes golang/go#41566

Change-Id: I5fb96a765cf4fb2572e2a8a2e560e02f0760023f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256818
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-09-24 17:36:56 +00:00
Danish Dua 06f3a46a9d gopls/internal/regtest: add benchmarks for completions
This change adds benchmarks for completions running against x/tools
codebase. We still maintain support for manually configured completion
benchmarks through the CLI; run instructions are added as comments in
code.

Change-Id: I3bcf7edac183397ad01755b767798925c4bd30ba
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256877
Run-TryBot: Danish Dua <danishdua@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Trust: Danish Dua <danishdua@google.com>
2020-09-24 16:27:44 +00:00
Rob Findley 463111b698 internal/lsp: add a command to generate the gopls.mod file
Wire up a command to generate a gopls.mod file for a multi-module
workspace. In the future, this can actually be used to manage the
workspace, but for now the file is just generated, not actually used.

For golang/go#32394

Change-Id: I8a53da8ac9337bde132c7d8ca8557467f368fc24
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256042
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-09-23 18:26:40 +00:00
Rob Findley 03f0cc1caa internal/lsp: interpolate variables in the sandbox
Change-Id: I818f0a6e77748720ba827ebc80719f344d95a436
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256581
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Trust: Robert Findley <rfindley@google.com>
2020-09-23 18:26:23 +00:00
Rebecca Stambler ba800b16d8 internal/lsp: ignore errors when finding workspace modules
Fixes golang/go#41558

Change-Id: If00cdb310575ac195ce8ebce7f156e0daa192b8d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256578
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-09-23 05:37:13 +00:00
Danish Dua f5e916c686 internal/lsp/source/completion: move search path to candidate
This change refactors deep completion to move search path to a candidate
instead of pointing to it in search queue. This removes the idea of
"being in deep completion" and instead a deep candidate is just a
candidate with a path from search root.

Change-Id: Iec6a0f4409c0c8793986d5c1063000205ed43477
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256417
Run-TryBot: Danish Dua <danishdua@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Danish Dua <danishdua@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-09-23 01:44:26 +00:00
Danish Dua a1f7ab681e internal/lsp/source/completion: move deep search to end of completion
Currently, we deep search top level candidates as soon as they're found,
which isn't necessarily leading to an overall breadth first search
approach. This change refactors completion to add candidates to search
queue instead and only call deepSearch once at the end.

Change-Id: I712b03c98b57680a1f1c95df2385f7f2ea6e1ed0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256259
Run-TryBot: Danish Dua <danishdua@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Trust: Danish Dua <danishdua@google.com>
2020-09-23 01:26:41 +00:00
Heschi Kreinick 82fe25c375 gopls/doc: improve enum value documentation
Add a new field to the options JSON, EnumValues. Use it to automatically
generate the documentation for enums. Fix the displayed type to be
"enum" rather than the full-qualified Go type name.

To make this easy, I changed the various enum constants to be strings,
with values matching their configuration values. It may be possible to
automatically parse them in the future, but we can get to that later.

The documentation for hoverKind's private values is a little janky. I
didn't want to build a way to hide them. We can hardcode it if we really
care.

Updates golang/go#33544.

Change-Id: Ia5cc958e347d5ff041068c57726d530809bb0f70
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256358
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-09-22 17:32:57 +00:00
Heschi Kreinick aeb8e36929 internal/lsp: remove multi-module support in tests
Mostly a rollback of CL 217541. No changes in the actual tests.

Change-Id: I910551d4750822bd2d8c5039d1cf194e42d01500
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256363
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: Robert Findley <rfindley@google.com>
2020-09-22 16:28:30 +00:00
phillc fa0125251c all: replace 'the the ' with 'the '
`find . -type f \( -name "*.go" -or -name "*.yaml" \) -print0 | xargs -0 gsed -i 's/the the /the /g'`

Change-Id: I422158bbe559d4eb00490f619306a94765dc18e4
GitHub-Last-Rev: d0df252001
GitHub-Pull-Request: golang/tools#253
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256258
Trust: Robert Findley <rfindley@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-09-21 21:00:52 +00:00
Rebecca Stambler a20a5e7f0e internal/lsp: rewrite createView to populate fields independently
The logic of incrementally populating the view was getting unnecessarily
complicated and hard to reason about. Split out helper functions that
we can use to create the view's fields before creating it.

Change-Id: I872fe22a9c2802668facf6b2d795b195aa47de00
Reviewed-on: https://go-review.googlesource.com/c/tools/+/255348
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2020-09-21 20:45:50 +00:00
Heschi Kreinick 4aa5c68dc7 internal/lsp: remove multi-module test cases
As we begin testing multi-module workspace, clean up existing
multi-module marker tests. Most of their coverage was redundant with reg
tests already. Add a couple to cover the remainder.

This is probably not strictly necessary but it was easier to remove the
tests than worry about how to support them in multi-module mode.

Change-Id: I54cca5eea60e0679759f7d39131c5cd015fb0154
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256361
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: Robert Findley <rfindley@google.com>
2020-09-21 20:20:10 +00:00
Heschi Kreinick 0f52b63a40 internal/lsp/tests: use NeedsGo1Point
Clean up a stray use of build tags rather than testenv.

Change-Id: Id645b4f6af1f770a47ea8ff3f0d16b14f25976c2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256360
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: Robert Findley <rfindley@google.com>
2020-09-21 19:08:06 +00:00
Heschi Kreinick ccabf82fa1 internal/lsp/cache: populate URI on files with errors
FileHandles with stat errors didn't have their URIs populated. It's
probably reasonable to expect URI and Kind to work on them.

Change-Id: Ic328b262803f93b5042da89a973859c598fa5beb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256359
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-09-21 18:19:13 +00:00
Jiayu Yi d647fc2532 cmd/benchcmp: mention deprecation in docs
A deprecation notice was added to benchcmp in a1f8cf0047, but there is no mention of it in the benchcmp docs at https://pkg.go.dev/golang.org/x/tools/cmd/benchcmp, so it may not be immediately obvious to new users.

This PR adds the deprecation notice to the documentation as well to make it easier to discover.

Change-Id: Ib49228abc140435023694173511caa4d3c6c0672
GitHub-Last-Rev: 8e19863394
GitHub-Pull-Request: golang/tools#252
Reviewed-on: https://go-review.googlesource.com/c/tools/+/255878
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Giovanni Bajo <rasky@develer.com>
2020-09-18 23:27:35 +00:00
Rebecca Stambler 78fed78f7d internal/lsp: handle modifications to the workspace module
We should be able to smoothly add and remove modules from the workspace.
This change moves the module-related fields from the view into the
snapshot so that they can be easily modified and recomputed. The
workspace module is now a workspaceModuleHandle.

Updates golang/go#32394

Change-Id: I6ade7f223cc6070a29b6021b825586b753a0daf1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/254940
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2020-09-18 22:49:48 +00:00
Danish Dua e94ab72881 internal/lsp/source/completion: improve import suggestion labels
This change improves the labels for import suggestions to only show the
last part of the path. Since VSCode fuzzy searches for labels in text
edit, we now return only the last part of path as text edit instead of
replacing the full import path. Just changing label while returning full
path leads to bad user experience.

Closes golang/go#35877

Change-Id: Ib10e7a3e030dc9b850ff1d9ec8d45240b75b64a3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/255837
Run-TryBot: Danish Dua <danishdua@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Trust: Danish Dua <danishdua@google.com>
2020-09-18 20:11:33 +00:00
Heschi Kreinick d56e4e40bc internal/lsp/cache: set GO111MODULE=auto in 1.16
1.16 wants to set GO111MODULE=on. There are, AFAIK, two differences
between "auto" and "on". First, if you're in a directory outside of GOPATH
and with no go.mod, "on" will run in module mode with GOMOD=os.DevNull.
I don't think we care very much about that. Second, if you're in GOPATH
with no go.mod, "on" will run in module mode, breaking GOPATH mode.

Breaking GOPATH mode may be desirable for the go command generally, but
for gopls I think it will lead to an unnecessarily bad user experience.
Users will find out when they do their first build or test; there's IMO
no need to also break their editor.

Flip the default back to "auto".

Change-Id: I280e001a9f7e80d65e68c0cb94353d70a7f5425e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/255781
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-09-17 22:16:17 +00:00
Jay Conrod 3791637d67 all: fix tests in preparation for GO111MODULE=on by default
This CL does not fix failures in ./gopls/internal/regtest, which will
be fixed separately.

In refactor/rename.TestDiff, add a go.mod file.

In internal/imports.ProcessEnv.buildContext, set an I/O hook if
GO111MODULE=off in ProcessEnv but not in the current process's
environment.

Context allows the user to set GOPATH, GOOS, GOARCH, and a few other
environment variables, but not GO111MODULE. Context.Import may return
different results than packages.Load if the latter is invoked with a
GO111MODULE value that differs from the caller's environment. Setting
an I/O hook forces Import to run in GOPATH mode, not invoking 'go list'.
This is undocumented, but it should be stable while GOPATH is
supported.

For golang/go#41330

Change-Id: I5679e8941e32dc95b05c234cb2e3fec5cabebced
Reviewed-on: https://go-review.googlesource.com/c/tools/+/255398
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
2020-09-17 22:14:52 +00:00
Danish Dua d148ae1e14 internal/lsp/source/completion: convert deep completion to bfs
This change converts deep completion from depth first search to breadth
first search.

Change-Id: Iebc7ba8d3acb44928220596065d4e8de53ea9b48
Reviewed-on: https://go-review.googlesource.com/c/tools/+/254542
Run-TryBot: Danish Dua <danishdua@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Danish Dua <danishdua@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-09-17 21:30:16 +00:00