Commit Graph

6292 Commits

Author SHA1 Message Date
Robert Findley 962260a678 internal/lsp/source: remove the unused source.DetectLanguage
Change-Id: If146b609f7dbf019cb11b27c73d685bcaf5a5075
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382236
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-04 14:03:07 +00:00
Robert Findley 3e30e21b53 gopls: remove the workspace_metadata command
Remove the workspace_metadata command, as VS Code no longer needs this
to run workspace commands (it can use go.work instead).

Updates golang/go#44696

Change-Id: Ife579a15e64969c4301e4508e18b7c8a8b633b9f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382235
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-04 14:02:58 +00:00
Robert Findley 25d2ab26ce internal/lsp/cache: fixes for workspace invalidation
This CL fixes a several bugs in workspace invalidation:
 - When invalidating the workspace due to a change in gopls.mod or
   go.work files, we should not update the workspace if the change does
   not parse. There was a comment to this effect, but it was not
   properly implemented.
 - Check go.work before gopls.mod, consistent with our intitial
   workspace load.
 - If we get an 'unchanged' change (such as a save) to go.work, don't
   continue looking for gopls.mod.

A regression test that inadvertently relied on our mishandling of broken
go.work files is updated to have the correct syntax. A new regtest
expectation is added to assert on a clean workspace.

For golang/go#44696

Change-Id: I2b7e739573e225cadfbf8cc892a0b5daf0191e40
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382115
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-04 14:02:15 +00:00
Robert Findley 8d915b1238 internal/lsp/cache: simplify workspace construction
Remove some duplication in the construction of cache.workspace
instances.

For golang/go#44696

Change-Id: Ic955fa3f9a574781f627c550694f0b87ad2013e1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382114
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-04 14:02:00 +00:00
Robert Findley 77f5fa5142 internal/lsp/cache: replace old go.work parser with x/mod
Gopls was using an old version of workfile support in x/mod that did not
support the 'use' syntax.

Upgrade to x/mod@master, and update tests accordingly.

For golang/go#44696

Change-Id: I87841cd1322d7b1aa0fbc929838746ea600bee77
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382078
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-04 14:01:19 +00:00
Robert Findley 4da8ceb6f1 internal/lsp/source: remove the unused UpdateUserModFile invocation flag
Change-Id: I4325417e4d97d3ab82551c2fa0382aa3d962a781
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382077
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
2022-02-03 22:05:07 +00:00
Shoshin Nikita 727dfdb191 internal/lsp/source/completion: add conventional acronyms for type names
This change adds a list of conventional acronyms that are used for function
completion. For example, "err" for "error" and "tx" for "sql.Tx" or "sqlx.Tx".

Fixes golang/go#48260

Change-Id: Iff951ee58c0c95389d474cc45dfd84b483ff71e3
GitHub-Last-Rev: 05ccd5a2fe95e2e0504d28230308c4888477a977
GitHub-Pull-Request: golang/tools#363
Reviewed-on: https://go-review.googlesource.com/c/tools/+/381969
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-02-03 15:53:42 +00:00
pjw c009ab4a1f internal/lsp/completion: the inserted text should be what is shown to the user
CompletionItem.Label is what is shown to the user. Unless InsertText is
overridden by there being a TextEdit, InsertText should be the same
as Label.

Change-Id: I200739fbdfca19aa33154d5391b3ebcc79dd7af5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382243
Run-TryBot: Peter Weinberger <pjw@google.com>
Trust: Peter Weinberger <pjw@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-03 15:40:54 +00:00
Robert Findley eeb95ae5ed gopls: make 'fastfuzzy' the default fuzzy matcher for workspace symbols
For dense queries, the fastfuzzy matcher is around 3x faster. It also
has improved scoring for exact matches of CamelCase words or path
segments.

Fixes golang/go#50016

Change-Id: I04cae11cbc54de59d54733836876a9ee759c80b6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382394
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
2022-02-03 14:26:36 +00:00
Robert Findley ea5e1dc8bc internal/typeparams: add a helper to return the origin method
With instantiated types, method objects are no longer unique: they may
be instantiations of methods with generic receiver. However, some
use-cases require finding the canonical method representing the method
in the source. For these use-cases, provide an OriginMethod helper.

For golang/go#50447

Change-Id: I6f8af3fb5c5eeefb11f8f3bdba54cd6692ca389f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380554
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Tim King <taking@google.com>
2022-02-03 14:02:38 +00:00
Bryan C. Mills a739c97304 internal/lsp/fake: retry ioutil.ReadFile on plan9 if it fails due to exclusive use
Fixes golang/go#50840.
(Maybe.)

Change-Id: I22d217f3706308b51d5b2ac84a781c50a6a41336
Reviewed-on: https://go-review.googlesource.com/c/tools/+/381734
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-02-03 05:59:13 +00:00
Bryan C. Mills 82366c6960 internal/lsp/fake: in WriteFileData, retry writes that fail with ERROR_LOCK_VIOLATION on Windows
The 'go' command reads the main module's 'go.mod' file with the file
locked. If 'gopls' starts a 'go' command in the background that reads
the 'go.mod' file, there is a narrow window in which that read can
race with the test's ioutil.WriteFile.

This change retries the write (as a user would probably do), fixing
the test failure. However, I suspect that there may be a broader UX
issue here that it will mask: in order to actually avoid the race
without a locking error, something in the LSP protocol needs to be
synchronizing gopls-initiated reads with editor-initiated writes. The
test failure this fixes indicates that that synchronization seems not
to be happening.

Fixes golang/go#50971

Change-Id: Iba140277bf957bae4937cc23f62d3aac817a7d36
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382414
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-02-03 05:58:33 +00:00
Ian Cottrell f6067dc943 gopls: cleanup the main help pages
This no longer has an invalid usage line, and mentions the help command.
It also mentions the no command form that is the same as serve.

For #41860

Change-Id: I9add50d295e1eb66152876617f27761a9441e67f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/367842
Trust: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-02 14:57:28 +00:00
Ian Cottrell dfda270eba gopls: use the = form in flag parameter printing rather than a space
For #41860

Change-Id: I9956d06aa26df54f57a4fedb30b36fe39f19ee3e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/367840
Trust: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-02 14:56:55 +00:00
Ian Cottrell 5ad7054788 gopls: add long forms for all the 1 rune flags
Also modify the printing so that it groups flags that work on the same
value into the same flag usage line.

For #41860

Change-Id: I97fdd3e64f24b22c15780b636789f512eb46ed2c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/367838
Trust: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Ian Cottrell <iancottrell@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-02-02 14:56:23 +00:00
Ian Cottrell 217a9fc29a gopls: take control of the flag printing
Add a copy of flag.PrintDefaults so that we can make changes.
This CL does not actually modify anything (although it does have
to detect the private stringValue type a slightly different way)

For #41860

Change-Id: I19512041f9c1bfde56226aea48302cd63cf670e2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/367837
Trust: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-02 14:52:21 +00:00
Ian Cottrell afd524fc39 gopls: clean up the help text
This makes lots of changes to make the help text more self
consistent, and fix up some broken things.

For #41860

Change-Id: I79f7f6ab12a3a833d15f53b3cd71208dfa1d6e10
Reviewed-on: https://go-review.googlesource.com/c/tools/+/367835
Trust: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-02 14:52:08 +00:00
Ian Cottrell ec9a7decbe gopls: write out the raw usage text
This adds a small script and uses it to write all the help text
to files.
This will be used to show the diff of a collection of changes to
come.

For #41860

Change-Id: Iaef52365d421dd3c375d22ac5a1f7c5eb6b69ac2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/367834
Trust: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-02 14:51:55 +00:00
pjw 461d130035 internal/lsp: include receiver type parameters when completing receivers
In
type SyncMap[K comparable, V any] struct {}
func (s *Syn
Syn sould be completed as SyncMap[K, V], as the type parameters
are required for receivers by the language definition.

fixes golang/go#50684

Change-Id: I6946d41c49df8bbd336225718c36e3c17dde0b6f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380354
Trust: Peter Weinberger <pjw@google.com>
Run-TryBot: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Muir Manders <muir@mnd.rs>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-02-01 13:36:13 +00:00
Robert Findley 263785d774 gopls: update dependencies post-release
This breaks the build at Go 1.12, as documented in golang/go#50827.

Fixes golang/go#50827

Change-Id: Ic7c122757e53981c5ee8f7fdf74fe276895717f2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380555
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-01-31 22:10:16 +00:00
Robert Findley 8e9bdc58e5 gopls: document that v0.7.5 is the final version to support Go 1.12
For golang/go#50827

Change-Id: Ib59aa4431dcc492db9436c19f43872781679f789
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382075
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-31 21:11:00 +00:00
Hana 492cf3ac49 doc: update the instruction to use beta2
And include the link to the milestone and a known issue

Change-Id: Iaae07cdf1a533da44fd15e0692b29e4173ed879f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/381016
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-31 20:30:41 +00:00
Bryan C. Mills 939c2c050f godoc/redirect: close HTTP response bodies in TestRedirect
In https://go.dev/issue/50879, we observe ECONNRESET errors from
'dial' in TestRedirect for various paths. That seems to imply that a
unique connection is being dialed for each path — but these
connections are all going through http.DefaultTransport, which has a
30-second keepalive, and the test takes well under that amount of time
to complete.

The only reason we would be dialing a connection per request would be
if the connection itself leaks — and, indeed, inspecting the test in
more detail it fails to close the response body.

I don't know why failing to close the response body would lead to
ECONNRESET errors, but at the very least fixing that issue should
reduce the number of 'dial' operations and thus the number of
platform-specific failure modes.

Fixes golang/go#50879.
(Maybe.)

Change-Id: I5af47ee3683c54106424c66e94b021a0ec7e6d2d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/381736
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-01-28 18:44:56 +00:00
Zvonimir Pavlinovic 0f0bbfd77b go/callgraph/vta: avoid panic on missing function definitions
For golang/go#50670

Change-Id: I86d4aee70584cf255f0972e56726b29555120e6d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380795
Reviewed-by: Guodong Li <guodongli@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Tim King <taking@google.com>
2022-01-27 20:56:17 +00:00
Robert Griesemer 845bb90a1d go/types/objectpath: update objectpath tests for TypeString changes
Enable a test case that uses comparable, now that its type string
has been adjusted.

Follow-up for CL 380999.

Change-Id: I5ce729e42234d7539a464d0aafba5a7f53d59625
Reviewed-on: https://go-review.googlesource.com/c/tools/+/381234
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-27 15:54:53 +00:00
Robert Findley be5769ca0a go/types/objectpath: update objectpath tests for TypeString changes
Uncomment (and adjust) test cases that were broken due to type parameter
type/object strings.

Comment out a test case that uses comparable, while its type string is
being adjusted.

Change-Id: I79fa2081f4a8acfe1bf23da61289272bde8ad034
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380999
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-26 21:43:32 +00:00
Zvonimir Pavlinovic 135791db47 go/callgraph/vta: move test code to testdata/src
This is a more common practice.

Change-Id: I45e37219a4d813a75fb239f0ce309489abe3616b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380794
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Guodong Li <guodongli@google.com>
Reviewed-by: Tim King <taking@google.com>
Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
2022-01-26 21:43:19 +00:00
pjw fe74b5f080 internal/template: return available semantic tokens even on template error
Fixes golang/go#50801

Change-Id: Ic5c541d6244bd56b90bee204be7c2b2fdfa90264
Reviewed-on: https://go-review.googlesource.com/c/tools/+/381014
Run-TryBot: Peter Weinberger <pjw@google.com>
Trust: Peter Weinberger <pjw@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-26 20:10:56 +00:00
pjw 772a39974b internal/template: return a Source with template diagnostics
Template diagnostics now return Soure 'template' instead of no Source.

Fixes golang/go#50786

Change-Id: Ifd7f26ffcee238b7168667c259c6b0006f8c03e6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380974
Run-TryBot: Peter Weinberger <pjw@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Trust: Peter Weinberger <pjw@google.com>
2022-01-26 16:53:13 +00:00
Bryan C. Mills c20fd7c261 internal/lsp/regtest: eliminate arbitrary timeouts
We care that gopls operations complete within a reasonable time.
However, what is “reasonable” depends strongly on the specifics of the
user and the hardware they are running on: a timeout that would be
perfectly reasonable on a high-powered user workstation with little
other load may be far too short on an overloaded and/or underpowered
CI builder.

This change adjusts the regtest runner to use the test deadline
instead of an arbitrary, flag-defined timeout; we expect the user or
system running the test to scale the test timeout appropriately to the
specific platform and system load.

When the testing package gains support for per-test timeouts
(golang/go#48157), this approach will automatically apply those
timeouts too.

If we decide that we also want to test specific performance and/or
latency targets, we can set up specific configurations for that (as
either aggressive per-test timeouts or benchmarks) in a followup
change.

For golang/go#50582

Change-Id: I1ab11b2049effb097aa620046fe11609269f91c4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380497
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-25 21:51:33 +00:00
Bryan C. Mills 97de9ec466 cmd/fiximports: skip TestDryRun on plan9-arm
For golang/go#50775.

Change-Id: I229263c840f406926b1f7c91de2400d4a18f3e16
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380495
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2022-01-24 16:42:25 +00:00
Bryan C. Mills 2cc1836031 cmd/callgraph: skip TestCallgraph on the windows-arm64-10 builder
We don't know whether this failure is due to a Go bug or a platform
bug, so we'll skip it on the one builder to reduce noise, but not the
GOOS/GOARCH as a whole. If we do not observe failures on other
windows/arm64 builders, we can perhaps chalk it up to a platform bug.
If we do observe failures on other builders, then we'll have more data
to investigate with.

For golang/go#50706

Change-Id: I52511dd4a5cff80953823d9cf901975ff4657457
Reviewed-on: https://go-review.googlesource.com/c/tools/+/379734
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
2022-01-24 16:42:11 +00:00
Bryan C. Mills 135972eb89 gopls/internal/regtest/codelens: use the test's deadline instead of a hard-coded timeout
We may want to generalize this to have regtest.Run always derive the
default timeout from the test's deadline. In the meantime, this is a
more targeted fix for the specific timeout in TestGCDetails.

Fixes golang/go#49902
(Maybe.)

Change-Id: Ie15735dc7b0d462ec047d3f3d8a2eceeb4411fa0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380496
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-24 16:28:24 +00:00
Robert Findley 84f205d75e internal/typeparams/example: start adding a guide to generics for tools
This CL begins adding a guide for the new APIs introduced with Go 1.18
to support writing tools that understand generic Go code.

For now I've added a summary of the new APIs, an initial example, and
some discussion of the typeparams package. Subsequent CLs will add more
examples, and polish.

Updates golang/go#50447

Change-Id: I4ed8d7a2f43e748374d14f3f515673d69ab2d5a0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/377834
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: Dominik Honnef <dominik@honnef.co>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
2022-01-22 21:07:13 +00:00
Tim King 3c751cd15c passes/ifaceassert: supress typeparams reports
Supresses reporting when either interface is type parameterized.

In principle, we should be able to report when we know two interfaces
cannot be unified. This is more complicated with type parameters.
Waiting on go/types to provide this complex functionality.

Updates #50658

Change-Id: Ib767585c785aea12dbb9e337cc339881a63be57e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380014
Run-TryBot: Tim King <taking@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Tim King <taking@google.com>
2022-01-21 21:53:34 +00:00
Robert Findley e7c9de23ff internal/lsp/cache: remove unsynchronized write to snapshot.files
snapshot.GetVersionedFile already memoizes the file handle in
snapshot.files. There is no reason to do another write, and this write
is unsynchronized.

Fixes golang/go#50747

Change-Id: Ib196395135de6f22dd59169accb756665ad10e58
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380214
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-21 21:27:57 +00:00
Bryan C. Mills 342596760e gopls/internal/regtest/workspace: temporarily skip TestWatchReplaceTargets
This test has a high failure rate on the builders, and the failures
appear to be mostly platform-independent. This change skips the test
until the failures can be diagnosed and fixed.

For golang/go#50748

Change-Id: Iadfda7345f3dcbafa61338469aa6dc45e1d85a49
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380215
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-21 21:08:53 +00:00
Marwan Sulaiman 9f83dd3691 internal/lsp/source: use the real type parameter in snippet completions
This change makes source.FormatVarType return the instantiated type
parameter instead of the actual AST expression because that will just
refer to the abstract type parameter and not the insantiated one.
I am not sure if this covers all edge cases or if there's a better
solution but I'm happy to adjust to whatever is appropriate.

Fixes golang/go#50623

Change-Id: I6e0b2d93c47c9a0502f2995ca8d3668a9a31c056
Reviewed-on: https://go-review.googlesource.com/c/tools/+/378714
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
2022-01-21 14:07:19 +00:00
Robert Findley 80963bc8f5 go/internal/gcimporter: support unique naming for blank type parameters
As described in golang/go#50481, in the existing export data schema
blank type parameters do not have unique names, and therefore types with
multiple blank (receiver) type parameters cannot be correctly imported.

This CL implements the fix proposed in that issue, using the schema
<prefix>.$<index> as the exported name of a blank type parameter, where
<prefix> is the qualifying prefix and <index> is the index of the type
parameter in its type parameter list. The importer is backwards
compatible with the old schema: it will continue to import <prefix>._ as
long as there are not multiple blank type parameters.

I considered not making the exporter change simultaneously with the
importer change, so that we interleave the corresponding changes in the
standard library. However, that made it harder to test the importer, and
updating both seems unlikely to cause problems.

For golang/go#50481

Change-Id: Id24428c6ea2b256312156894f9f76fa8e9ee38d4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/379855
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-20 20:23:52 +00:00
Robert Findley 25e1ac41e6 go/internal/gcimporter: remove the sanitizeName helper
It not necessary to sanitize object/type strings produced by go/types,
because they no longer contain subscripts.

Change-Id: I3ed41359d59b01ab2cf2ad4a6b587635ce4cecf2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/379854
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-20 20:08:31 +00:00
Robert Findley 9134808125 go/internal/gcimporter: add more assertions for generic import/export
Add additional assertions when comparing objects in imported packages.
In particular, cmpObj was skipping many assertions about top-level named
types that were not reachable from other declarations.

Change-Id: If8f6bee452d921b72550aed4e7ac1b31fa859f5e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/376114
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2022-01-20 20:08:23 +00:00
Bryan C. Mills ab35822fb7 gopls/internal/regtest/completion: temporarily skip TestPostfixSnippetCompletion
TestPostfixSnippetCompletion appears to produce racy writes to the
filesystem, and the failure mode does not seem to be
platform-specific. This skips the test to reduce noise until someone
has the time to investigate in more depth.

For golang/go#50707

Change-Id: I31c3aaf0cdb92ae2323cc8a926d3775d1433a9ff
Reviewed-on: https://go-review.googlesource.com/c/tools/+/379735
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-20 14:52:25 +00:00
Robert Findley 7c251d6b2f internal/typeparams: improve the package documentation
Update and expand on the package documentation for the
internal/typeparams package.

Change-Id: I2af16250580abf9e6b3a8692356faa498ba83f29
Reviewed-on: https://go-review.googlesource.com/c/tools/+/377654
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-19 20:29:36 +00:00
Robert Findley 2762b18206 internal/typeparams: simplify the IndexExpr API
The IndexExprData type of internal/typeparams was redundant now
that the typeparams.IndexListExpr type has been introduced. Remove it,
and change GetIndexExprData to an UnpackIndexExpr method, symmetric with
PackIndexExpr. With the IndexListExpr type, both UnpackIndexExpr and
PackIndexExpr can be moved to common.go.

Change-Id: I6c31f52ab594175decfbd1a4cd94b60a23a1e629
Reviewed-on: https://go-review.googlesource.com/c/tools/+/377235
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-19 20:29:28 +00:00
Robert Findley a71de3f351 gopls/doc: fix inconsistent rendering of enum newlines
We have inconsistent rendering of newlines in enums, as pointed out in
CL 314189 (that change edited the markdown directly, which won't work).

Change-Id: Ie39b80fe65287bd447d18cacdaea60b24b4bd08f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/369957
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-19 15:07:38 +00:00
Robert Findley 523d859406 internal/lsp/source: use the fastfuzzy matcher in experimental mode
The fastfuzzy matcher is around 3x faster than the fuzzy matcher for
queries that need to search a large number of symbols, and has improved
scoring due to built-in knowledge about the structure of Go symbols.

Enable it in experimental builds of gopls, with plans to enable it by
default in the next release.

For golang/go#50016

Change-Id: Ie2c333f248bb8397d92f52fbbfdd2bf623372d0a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/377434
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-19 15:06:54 +00:00
Robert Findley 6299a6dbc2 internal/lsp/cache: keep going on per-file workspace symbol errors
I'm not sure how to hit this in practice, since it appears that symbols
should only return errors with some type of corruption, but we should
keep going when searching for symbols in snapshot files.

Change-Id: I9fcf6cc92fdc943520e8890ece51d28ec46e8812
Reviewed-on: https://go-review.googlesource.com/c/tools/+/376363
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-19 15:06:41 +00:00
Robert Findley 21ca3b3a93 internal/lsp/source: parse symbol queries when using fastfuzzy
Hook up the fastfuzzy symbol matcher to our fzf-style query parsing, for
consistency with the (slow) fuzzy matcher.

In the past I had wanted to implement this natively inside the
SymbolMatcher, but it is much simpler to keep using combinators. In the
common case we'll just be using fuzzy matching.

For golang/go#50016

Change-Id: I1c62c8c8e9d29da570cb1e4034c2b10782529081
Reviewed-on: https://go-review.googlesource.com/c/tools/+/376362
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
2022-01-19 15:06:07 +00:00
Robert Findley 3737ecd836 internal/lsp/fuzzy: consider whole word matching in SymbolMatcher
In the new SymbolMatcher, add an additional scoring feature that
considers whether the matching pattern streak is part of a whole-word
match. This differentiates matches of "foo" against "pkg.foo" and
"pkg.foobar".

For golang/go#50016

Change-Id: Ib84ff13eee0b7ec23143325592cef9a41be07375
Reviewed-on: https://go-review.googlesource.com/c/tools/+/376361
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-19 15:05:25 +00:00
pjw a8c745991d internal/lsp: bring the LSP stubs up to date
There are no changes to the internals of gopls. THe newest version
of the LSP has support for notebooks.

Change-Id: I6d12350e195f459df14efe3b349fff4cc917470c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/379114
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Peter Weinberger <pjw@google.com>
Trust: Peter Weinberger <pjw@google.com>
2022-01-19 14:58:28 +00:00