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

5574 Коммитов

Автор SHA1 Сообщение Дата
Rebecca Stambler 5d65579003 go/packages: remove -mod, -modfile flags from build flags for go version
Use provided build flags may include -mod or -modfile, and these should
be removed before any go command calls that don't accept them.

Fixes golang/go#43418

Change-Id: Ie96626bced5093c67fc1890533f1f8cc03d42c80
Reviewed-on: https://go-review.googlesource.com/c/tools/+/280694
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: Michael Matloob <matloob@golang.org>
2021-01-05 21:02:02 +00:00
Pontus Leitzler b8e0803c79 internal/lsp/source: return all field funcs from outgoing callhierarchy
Outgoing callhierarchy didn't handle different functions defined as
field in a struct as separate functions since they were declared by the
same AST node.

This change adds the identifier name to the key, so that a function
must share both declaration node and name to be considered "the same".

Fixes golang/go#43456

Change-Id: Ifbced98f2e8fc3a303834f7cefbae66829b68d27
Reviewed-on: https://go-review.googlesource.com/c/tools/+/280618
Trust: Pontus Leitzler <leitzler@gmail.com>
Run-TryBot: Pontus Leitzler <leitzler@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2021-01-05 17:25:16 +00:00
Jan Steinke 6c3993fd31 gopls: update link to nvim-lspconfig gopls configuration
The README of nvim-lspconfig was restructured and now the link is out-dated. This change reflects the change and brings it up-to-date.

Change-Id: If8a871a31390ac98eb783f89b58d22d1a42cb7ef
GitHub-Last-Rev: 80416bf486
GitHub-Pull-Request: golang/tools#266
Reviewed-on: https://go-review.googlesource.com/c/tools/+/281254
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Trust: Robert Findley <rfindley@google.com>
2021-01-05 16:40:27 +00:00
Rob Findley 66568f37fe gopls/doc: add additional information on CI in contributing.md
Also add some documentation on the regression tests, to help if/when
contributors hit regtest failures.

Change-Id: I9dbff91cbbe58742848f15467d3d6356189d4e3c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/281672
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>
2021-01-05 16:36:11 +00:00
Daniel Martí 961d08dc12 gopls: bump gofumpt to v0.1.0
Largely no functional changes, but it's the first tagged release and it
has a few bug fixes compared to the previous version from September.

It pulls in new versions of x/mod and even x/tools itself, which is
amusing.

Change-Id: I9b889a162af14d75aa5ca2f448a29b18a555f572
Reviewed-on: https://go-review.googlesource.com/c/tools/+/280315
Trust: Daniel Martí <mvdan@mvdan.cc>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2021-01-05 16:30:49 +00:00
Rob Findley 2e889ff48d gopls/internal/regtest: support multiple workspace folders
This change both simplifies the options used to configure workspace
folders in regtests, and allows for configuring multiple workspace
folders. The WithoutWorkspaceFolders, RootPath, and NestWorkdir options
are all replaced by a single WorkspaceFolders option.

NestWorkdir was always a bit too magical, modifying the execution
directory within the runner itself. Instead, just explicitly move files
down into a nested directory.

runModfileTests was also a bit too much of a special case. Eliminate it
by adding functionality to run multiple times with different options.
Upon the way I started using literals to configure runs, and I think
this is cleaner. Let me know what you think about runMultiple, etc.
This overlaps with the execution modes, which could probably be
eliminated in a later CL.

For golang/go#42111

Change-Id: I56915d8930bc47561cc827b918621cff4b994226
Reviewed-on: https://go-review.googlesource.com/c/tools/+/276975
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: Heschi Kreinick <heschi@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2021-01-05 15:40:28 +00:00
Oliver Tan eb9b40eb24 cmd/goyacc: double ACTSIZE, NSTATE and TEMPSTATE
CockroachDB has yet again hit the limit of ACTSIZE. Following the
precedent set by CL 33585 and doubling the relevant ACTSIZE, NSTATE and
TEMPSTATE const variables.

Change-Id: Ic090c7744bc4f1ae0f69b0ffced9a5338e923643
GitHub-Last-Rev: 2f1e8ccfe3
GitHub-Pull-Request: golang/tools#259
Reviewed-on: https://go-review.googlesource.com/c/tools/+/274892
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-01-04 08:10:19 +00:00
pohzipohzi 2993f551b7 internal/lsp: avoid panic during interface assertion
This change fixes a panic in the non-standard request.

Fixes golang/go#43462

Change-Id: I216a56f96ca6159cb9b102183ba3a3eddd186889
GitHub-Last-Rev: 992e818f8a
GitHub-Pull-Request: golang/tools#265
Reviewed-on: https://go-review.googlesource.com/c/tools/+/281092
Reviewed-by: Peter Weinberger <pjw@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Trust: Rebecca Stambler <rstambler@golang.org>
2021-01-02 18:51:54 +00:00
Pontus Leitzler c4dccaf3ad go/analysis/passes/fieldalignment: add command
Add fieldalignment as a singlechecker.

Closes golang/go#43446

Change-Id: Ibc3bcc45087d56d429c66a74758b17bda01e7ef3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/280617
Trust: Pontus Leitzler <leitzler@gmail.com>
Run-TryBot: Pontus Leitzler <leitzler@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2021-01-01 21:42:03 +00:00
Rebecca Stambler 9ca8607e69 internal/lsp: save all possible keys for analyses, codelenses
The possible keys for analyses and codelenses are too long to enumerate
in settings, and we'd need to create enums for all possible analyzer
and code lens names, which is probably not feasible. Instead, collect
the list of possible values from the analyzers and command settings
generation and add them to enum values.

Also, handle default values by setting them in the enum keys instead of
one big default value. Quite a few hacks to get this right, but maybe
there are other better alternatives we can consider in the future.

Fixes golang/go#42961

Change-Id: I5c096862b5e8fb89fe5d6639b4f46c06492e49c4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/280355
Trust: Rebecca Stambler <rstambler@golang.org>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
2020-12-30 22:05:20 +00:00
Rebecca Stambler d2d86cca02 internal/lsp: restructure user options (CL 278433 continued)
This CL copies Heschi's structural changes to the options from CL 278433
and makes the necessary adjustments in the JSON and documentation
generation. Nested settings are grouped together and the "status" of a
given setting is also listed. Currently the only possible statuses are
"experimental" and "debug", but I will add "advanced" in a follow-up (to
indicate that a setting is only for advanced users).

The options "set" function still expects flattened settings to avoid
fundamentally changing people's current configurations, so VS Code Go
will just have to make sure to flatten the settings before sending them
to gopls (which should be easy enough).

No names of any settings are changed (Heschi's earlier CL adjusted the
experimental prefixes). As discussed offline, we've decided to prefix
any setting that we expect to delete with "experimental", and so we'll
leave existing setting names as they are.

Updates golang/go#43101

Change-Id: I55cf7ef09ce7b5b1f8af06fcadb4ba2a44ec9b17
Reviewed-on: https://go-review.googlesource.com/c/tools/+/280192
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: Suzy Mueller <suzmue@golang.org>
2020-12-30 21:54:22 +00:00
Rebecca Stambler 4a19ffb6e6 gopls/internal/regtest: await file changes in TestUseGoplsMod
Make sure metadata is reloaded after each file changed.

Change-Id: If3900f6fc2f99ff4eaf81b82d39e01e9f5dcb68e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/280695
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-30 16:32:07 +00:00
Rob Findley ef3185ba9c internal/lsp/cache: add a check for snapshot invariants
Check that some invariants are met when cloning the snapshot, in an
attempt to catch golang/go#43347

For golang/go#43347

Change-Id: I7404509027a1b0b0085133cba4d21d1006a52a57
Reviewed-on: https://go-review.googlesource.com/c/tools/+/280698
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-12-30 15:44:40 +00:00
Matheus Alcantara b8413747bb internal/lsp: fix autocomplete appends on imports
Autocompleting a import without quotes appends to the completion,
producing this result: `import math "math/"`.
This commit changes to skip completions when typing a import without
quotes, because the users can be typing the alias of the import.

Fixes: golang/go#42748

Change-Id: I7050989f1f90a6720c17f71f338e50fad1f01456
GitHub-Last-Rev: e7b189a04a
GitHub-Pull-Request: golang/tools#263
Reviewed-on: https://go-review.googlesource.com/c/tools/+/280652
Reviewed-by: 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>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Trust: Rebecca Stambler <rstambler@golang.org>
2020-12-29 22:18:35 +00:00
Rebecca Stambler 929a8494cf internal/lsp: restructure the way we report critical errors
The fragmentation of the critical error reporting is getting in the way
of small fixes. This change adds a GetCriticalError function that reports
critical errors, while ModTidy and WorkspacePackages no longer report
critical errors. Any function that wants to process critical errors
should call AwaitLoaded.

Some other smaller changes are made to account for these changes. One
change is that we may report multiple *source.Errors, with the
assumption that duplicate diagnostics will be caught by the diagnostic
caching. Also, any `go list` error message that ends with "to add it" is
now considered an error that gets the "add dependency" suggested fix.

Fixes golang/go#43338
Fixes golang/go#43307

Change-Id: I056b32e0a0495d9a1dcc64f9f5103649a6102645
Reviewed-on: https://go-review.googlesource.com/c/tools/+/280093
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2020-12-29 01:39:31 +00:00
Rebecca Stambler fbbba25c5f gopls/doc: generate documentation for analyzers
Analyzers are configured in the internal/lsp/source/options.go file as
well as settings, and we can generate documentation for them without
even using reflection. We add documentaton for each analyzer and list
whether or not it is enabled by default.

Change-Id: If0ffcd422f3f4a99ca3645c35197925ea1cc1616
Reviewed-on: https://go-review.googlesource.com/c/tools/+/280352
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: Suzy Mueller <suzmue@golang.org>
2020-12-29 01:23:49 +00:00
Rebecca Stambler 84d76fe320 internal/lsp: fix unimported completions with -mod=readonly
When -mod=readonly and GOPROXY=off are set, the newly imported package
is not type-checked with the new import until it is reflected in the
go.mod file. In such cases, we can continue treating the package as
unimported and get symbols through unimported completions.

Fixes golang/go#43339

Change-Id: I864c2c6738b537093c0670a266e9030af33f2d36
Reviewed-on: https://go-review.googlesource.com/c/tools/+/280095
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>
2020-12-28 20:48:37 +00:00
Rebecca Stambler 0661ca7ea1 gopls/internal/regtest: show line numbers if TestUseGoplsMod fails
I can't repro the failure now, but on a few earlier CLs this week, this
test failed. Getting the actual line number in the failure message and
failing early would still be helpful, so I think this CL is still worth
merging in case it happens again.

Change-Id: I5ef0490ed103bea03aed018b45c9d1f383decc70
Reviewed-on: https://go-review.googlesource.com/c/tools/+/280533
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
Trust: Suzy Mueller <suzmue@golang.org>
Trust: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-28 18:51:49 +00:00
Eric Chiang 13ff2212a5 internal/lsp/cmd: include new name in rename help message
"gopls rename" appears to require a new name as a positional argument
but the command line help message doesn't include it. Update the help
message.

Change-Id: Iea769d2095b0642ebbacce128da336ec0dc56828
Reviewed-on: https://go-review.googlesource.com/c/tools/+/280472
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Trust: Rebecca Stambler <rstambler@golang.org>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-28 17:52:27 +00:00
Ainar Garipov 0f6027f0cc gopls/doc/vim.md: add table of contents, improve neovim docs
Change-Id: Ibc56cb676200df4282eeb38d0f63f239d2f962ab
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278832
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
2020-12-28 17:44:24 +00:00
Rebecca Stambler 34cd474b99 internal/lsp: use an enum for GC annotations settings
The annotations map should use an enum to indicate expected values. For
now, we reuse the EnumValues to expose the information in the settings.
Later, we'll create a separate EnumKeys field to expose this information
more correctly.

Also, adjust some of the logic that applies the settings because it was
incorrect.

Both gopls/doc/settings.md and internal/lsp/source/api_json.go are
generated files.

Updates golang/go#42961

Change-Id: Ifb032b70caaae73defe9a540df20d098d313e68e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/280354
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-12-28 16:22:55 +00:00
Pontus Leitzler b1c90890d2 internal/lsp/source: do not panic in "var func" outgoing callhierarchy
When trying to get outgoing call hierarchy from an var func like:

func main() {
    foo := func() {}
    foo()
}

gopls crashed with a panic.

This change makes it return an empty call hierarchy instead.
It also adds support for testing outgoing calls where the expected
result is 0 items, to be able to test this change.

Fixes golang/go#43376

Change-Id: Icd91bf54cb4fbd5203f5865f0ff9d81365c27d5d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279469
Trust: Pontus Leitzler <leitzler@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Pontus Leitzler <leitzler@gmail.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-12-26 21:56:59 +00:00
Rebecca Stambler 2b0845dc78 gopls/release: add a command to validate the gopls release process
The gopls release process has a number of steps which can be easily
forgotten, but they are also easy enough to check. In the future, we can
certainly automate this process further, but this basic program will
validate that mistakes like golang/go#43256 are not made again in the
future.

Change-Id: I04641ae202bc6615f2e4c8810b5dab4885d37fd4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279715
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-12-24 04:30:29 +00:00
Rebecca Stambler 57089f8fd7 internal/lsp: remove dependencies using text edits when necessary
golang/go#43335 explains the issues with using `go get module@none`,
which will only be resolved in Go 1.17. In the meantime, we use the
go command whenever possible, but if the module is not tidied, we
have to use textual edits instead. This means the go.sum file will not
be accurately updated to remove the dependency, but unfortunately, I
don't believe there is anything that we can do in that case.

Fixes golang/go#43335

Change-Id: I771f68f34a6136e73e9dd82b692ed4c235c3b293
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279716
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2020-12-24 00:32:54 +00:00
Matheus Alcantara 834755c7db internal/lsp: add tests to set configuration options
Added some tests to hoverKind, matcher, env and directoryFilters
of configuration options.

I'm also add a validation on `env`configuration, to initialize the map if is nil to avoid the risk of inserting the values in a nil map. Please let me know if this validation is unnecessary.

Fixes golang/go#34244

Change-Id: I387ad0a393d981d070002c7e3736acad7b2191bf
GitHub-Last-Rev: 4fe3547543
GitHub-Pull-Request: golang/tools#261
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278072
Trust: Robert Findley <rfindley@google.com>
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: Rebecca Stambler <rstambler@golang.org>
2020-12-23 23:03:58 +00:00
Rob Findley bdbb3c917f internal/lsp/cache: only reload the workspace on saved changes
Invalidating the workspace on any change to a go.mod can render a
workspace unusable. Only invalidate when changes are saved.

Additionally, invalidate the workspace if there is a saved change to
tracked go.sum changes.

Fixes golang/go#42529
Fixes golang/go#42815

Change-Id: I5d903013b33b932eca4998513e3d0a534b2e5a61
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279720
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-12-23 22:53:30 +00:00
Rob Findley 3e0a2b754c gopls/internal/regtest: skip a some new builders where regtests time out
Updates golang/go#42789
Updates golang/go#43355

Change-Id: Ic344237e492b08c30c4d86db6a6a39a561e2d27b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/280092
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: 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-12-23 22:32:11 +00:00
Rob Findley f6952e403d internal/lsp/cache: fix some package event tags
Package.ID() is far more useful to tag on events, as it disambiguates
multiple packages with the same path.

Change-Id: I03fd69f64641eb17155ca72ed2ef19641b75f004
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279722
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: 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-12-23 20:03:49 +00:00
Ainar Garipov 9cbb1efa77 internal/lsp/source: add the shadow analyzer
Fixes golang/go#43245

Change-Id: I4b51d8bfcb815c29339754637114558c62b0f6bd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279395
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
Trust: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-12-23 17:49:54 +00:00
Rebecca Stambler 3fa0e8f87c gopls: disable TestTemplate on Android
The test doesn't pass on Android, likely because of the use of
go/packages.

Change-Id: If31ea39e9dfbbb1dc0d9c123a43384cb552cd025
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279712
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-23 01:07:50 +00:00
Peter Weinbergr f2e330f490 gopls/test: add type checking for debug server templates
When internal data structures in gopls changed, the templates driving
the debug server failed because fields or methods they relied on
had gone away. At some cost, this change adds tests that all the
fields and methods in the templates can be satisfied.

The test assumes that all the template uses are through render() in
debug/serve.go. It checks that is list of templates is the same
as the server's, and then type checks each template.

The costs are
1. the template type checking is done by a new external dependency,
github.com/jba/templatecheck
2. To avoid adding a new dependency to x/tools, the test is in
the gopls module, not the debug package, so variables from the
debug package have to be exported

In an ideal world the debug package, and much of internal/lsp,
would be in the gopls package. In that case the cost 2 about could
be avoided.

In an ideal world, the core runtime template packages would
contain template checking code, and cost 1 would be unnecessary.
In a more likely (or not so distant) world, perhaps jba would move
(or allow us to move) the template check package into x/tools.

Change-Id: I36b509a00cbdcb5323ee1af3c1193b603c7a907f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/277292
Run-TryBot: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Trust: Peter Weinberger <pjw@google.com>
2020-12-22 16:32:15 +00:00
Rebecca Stambler 1965356128 internal/lsp/mod: fix misplaced code lens with individual requires
If there is no require block, we were misplacing the Upgrade code
lenses.

Change-Id: Ic7ea5f254747bc1e1fc8aa42d0facc52702b745b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279172
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-12-21 20:10:19 +00:00
Rebecca Stambler b57d1c5b4a internal/lsp: return an error if code action has no title
Hopefully this will prevent missing titles in the future. Confirmed this
works by removing an existing title.

Change-Id: Id8c7fa2eaffd043b5c66976d945376d6558f75bf
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279173
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-12-21 19:58:07 +00:00
Rebecca Stambler ae774e9781 internal/lsp: don't show duplicate diagnostics for go.mod errors
We were getting duplicate diagnostics for certain mod tidy diagnostics.
The correct fix is to separate out the generation of such diagnostics
so that duplicates don't occur, but for now, this is the simplest fix.
I wanted to add a test, but my repro case involves `go clean -modcache`
and checking that a version cannot be downloaded, which doesn't work
with the file-based GOPROXY. I will probably have a CL at some point
that cleans up the way these diagnostics are produced.

Change-Id: I542648b4eae7aced15f720db6233c852879f2a26
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278917
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-12-18 02:47:24 +00:00
Rebecca Stambler 5b06639e57 internal/lsp/source: only show "run file benchmarks" if available
We were previously showing them even if there were no benchmarks to run.

Fixes golang/go#43239

Change-Id: I51d1de12e86009cca6d8ea41208949ed01484f6a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278780
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-12-17 23:51:54 +00:00
Rebecca Stambler 11a5667e27 gopls/internal/regtest: test metadata validation only on save for go.mod
There was never a test that actually confirmed that golang/go#42529 was
fixed, so it never actually was.

Updates golang/go#42529

Change-Id: I4264162e98c5fde804c780e098a1d4e21a2d88d8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279033
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-12-17 23:10:36 +00:00
Cuong Manh Le 5b43ef9348 go/analysis/passes/fieldalignment: filter comments from suggested fix
go/ast has problem with comments from its design, for now, best way is
to get rid of the comments.

See https://github.com/golang/go/issues/20744 for general problem.

Updates golang/go#43233

Change-Id: I7c29dc9d0573f5f894859cd8b24e010a777ebba2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278872
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-12-17 22:11:02 +00:00
Rebecca Stambler 4b31ac340b gopls/internal/regtest: test that accepting fix removes diagnostics
This test currently fails, as we don't treat go.sum updates as
invalidation events.

Updates golang/go#42815

Change-Id: I01a94ac99293a425ff7cff5d5effab19d0fd2772
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279032
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-12-17 22:00:28 +00:00
Rebecca Stambler 008e477491 internal/lsp, gopls: recover from go-diff panics
This CL handles the panic in the sergi/go-diff library which has not
yet been resolved. We add an error return to the ComputeEdits function
and return an error if there is a panic. I'm not sure if this is the
best approach, but it does seem better than allowing the server to
crash.

A concern would be that the user wouldn't know why their code wasn't
being formatted, but hopefully they might look through the logs and
notice the error message. At least, other features would continue
working. The best fix will definitely be the fix for the panic, but that
is not yet available.

Threading through the error return was not pretty, but I thought it was
probably worth doing since it could be needed in other situations.

Updates golang/go#42927

Change-Id: I7f0c05eb296ef9e93b4de8ef071301cdb9dce152
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278775
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>
Trust: Rebecca Stambler <rstambler@golang.org>
2020-12-17 16:56:54 +00:00
Rebecca Stambler 48e5bd1105 internal/lsp: add titles to `go mod tidy` and update go.sum fixes
These were missing titles, which was showing up empty for users in the
VS Code UI and leading people not to trust the fixes.

Also did a find references on SuggestedFix to confirm that we always
set the title in other cases.

Fixes golang/go#43234

Change-Id: I8d0f272c383a2e1a364aefcec6650988d18d4fb4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278778
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-12-17 16:18:45 +00:00
Hana fa10ef0b87 internal/lsp/source: update codelenses example
And regenerate docs and api_json.go

Change-Id: I7504c5257893617adcc0b657b61feb3cdb235061
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278356
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-15 19:20:05 +00:00
Pontus Leitzler 6307297f46 go/analysis/passes/fieldalignment: support fields without name
The flattening didn't account for fields without name resulting in a
panic when calculating suggested fixes for such struct.

They are now added while flattening and there is also a test to ensure
that it works.

Change-Id: I8f8740c8d9132d10fb09053a322633eb29e8bcf8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278372
Trust: Pontus Leitzler <leitzler@gmail.com>
Run-TryBot: Pontus Leitzler <leitzler@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-12-15 17:11:52 +00:00
Rob Findley d93e913c1a internal/lsp/debug: hook runtime/trace into event spans
Existing spans defined within gopls are leveraged to add runtime/trace
tasks, regions, and logging.

This made it easier to understand gopls' execution, though we still have
relatively sparse logging (arguably because we're conscious of the fact
that logs are reflected back to the LSP client). Add a new log package
with the concept of log level to facilitate excluding trace logs from
the LSP.

Add a little bit of additional instrumentation to demonstrate the usage
of the new package.

Change-Id: Id337be806484201103e30bfe2c8c62c7d7c363c7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275252
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-12-11 18:50:31 +00:00
Ian Lance Taylor abf6a1d87e go/analysis/passes/structtag: recognize multiple keys per tag
As of Go 1.16 the reflect package now supports multiple keys per tag.

For golang/go#40281
Fixes golang/go#43083

Change-Id: I55cdc35c857a5e73dc009c2842d7bd83c63d7712
Reviewed-on: https://go-review.googlesource.com/c/tools/+/277092
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tim King <taking@google.com>
2020-12-11 02:55:43 +00:00
Rob Findley 6d345e82f1 gopls/internal/regtest: remove redundant 'With' from run options
Now that the correct way to invoke regtests is via withOptions(...).run,
all the 'With' prefixes in option names seem redundant.

Change-Id: Icbbb00e15d034726d1e0cb13ff82b4f832add286
Reviewed-on: https://go-review.googlesource.com/c/tools/+/276974
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-12-10 18:12:37 +00:00
Rebecca Stambler f31efc5a5c internal/lsp: add an orphaned file diagnostic for nested modules
This change adds a diagnostic and error message that appears when a user
edits a nested module in legacy mode. At first, I thought a diagnostic
would be enough, but it's actually quite difficult to spot it when you
have a bunch of "undeclared name" diagnostics caused by the nested
module, so I figured a progress bar error message would also be useful.

This error message just indicates to the user that they should open the
nested module as its own workspace folder.

Also, while debugging this, I noticed that command-line-arguments
packages can have test variants, which we were never handling.
So I addressed that in this change.

Fixes golang/go#42109

Change-Id: Ifa6f6af401a3725835c09b76e35f889ec5cb8901
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275554
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2020-12-10 16:46:18 +00:00
Peter Weinbergr b71f123c27 internal/lsp/debug: show Options in gopls debug server
Provide both the current values and default values of Options. These
are in the Sessions tabs.

Display in the debug server, including the Options, needs work.

Change-Id: I970fa65631702b79f6e5f8089a5b1cc5daa8334e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275540
Trust: Peter Weinberger <pjw@google.com>
Run-TryBot: Peter Weinberger <pjw@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2020-12-10 16:13:38 +00:00
Rebecca Stambler a543418bbe internal/lsp: only diagnose views affected by a change
For every file change, we want to diagnose the resulting snapshots.
However, we also want to diagnose the file in its "best possible" view
(for example, for a nested module, we should use the inner module rather
than the outer module).

Add a bestView function that operates on a set of views, which allows
us to a pick a view out of the *views affected* by a file modification,
not out of *all* of the views in the session. This means that we can
pick the best view, if any, for each file change and then only return
the snapshots that we should diagnose, as well as the changed URIs for
those snapshots.

Fixes golang/go#42890

Change-Id: Iad23d5ed4832dfd857f1424a7244cf3bd8900e3b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/274235
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-12-08 23:30:53 +00:00
Rebecca Stambler 5cdc27446b internal/lsp: remove the last diagnostics pop-up warning
The "you are neither in a module nor your GOPATH" warning doesn't fit
our current notification style, so adjust it to appear as a progress
report and clean up the associated tests.

Change-Id: I32b96f17f3b9715403e465e3e0f9705f5d859147
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275537
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-12-08 23:26:54 +00:00
Rob Findley ef0c635082 gopls/internal/regtest: skip builders on which regtests time out
Certain builders have been failing consistently due to regtests timing
out. Attempt to clean-up the tools build dashboard by skipping the
regtests on these builders when -short is set.

Change-Id: Id359eb30cc5e0125e7568b972495a0599c3ccbc8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/276255
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-12-08 22:50:42 +00:00