Commit Graph

6308 Commits

Author SHA1 Message Date
Nooras Saba 2ff4db7dab go/analysis/passes/tests: Check malformed fuzz target.
This will validate that first letter after FuzzFoo() should be uppercase
Also, following validation will be performed for f.Fuzz() calls :
	1. f.Fuzz() should call a function and it should be of type (*testing.F).Fuzz().
	2. The called function in f.Fuzz(func(){}) should not return result.
	3. First argument of func() should be of type *testing.T
	4. Second argument onwards should be of type []byte, string, bool, byte,
	   rune, float32, float64, int, int8, int16, int32, int64, uint, uint8, uint16,
	   uint32, uint64

For golang/go#50198

Change-Id: I540daf635f0fe03d954b010b9b5f8616fd5df47a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/374495
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Peter Weinberger <pjw@google.com>
2022-02-16 18:26:19 +00:00
Tim King 11109f6142 go/ssa/ssautil: Initialize Instances field.
Initializes the Instances field during BuildPackage.

Updates golang/go#48525

Change-Id: I4d60d644443733930528e2109db75589511de6f4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/385775
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Tim King <taking@google.com>
2022-02-15 21:36:54 +00:00
Tim King 33002eafb2 go/loader: Initialize (types/Info).Instances field
Initialize the Instances field of PackageInfo.Info during importing.

Needed for go/ssa and similar users.

Updates golang/go#48525

Change-Id: Ibacf925e677ec6e90068b90a4f381d96c22338cc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/385774
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2022-02-15 21:36:29 +00:00
Michael Matloob be40034de7 internal/lsp: add support for formatting go.work files
Wired through support for calling x/mod's go.work formatter on go.work
files into LSP. Tested it by hand in editor using the "Format Document"
command. Added a test case to workspace_test regtest, though I'm not
totally sure the test is correct.

For golang/go#50930

Change-Id: Ied052ded514bb36f561737698f0e2d7b488158e7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/383774
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-02-15 17:15:32 +00:00
Suzy Mueller 2405dce5ad internal/lsp: use placeholders with prepare rename
When a prepare rename request is issued on an package
import with no alias, the range returned by prepare
rename has length 0. This by itself does not provide
enough information to the client about what the original
name of the import statement. By returning a range and
a placeholder, this allows the client to correctly present
the information about what is being renamed to the user.

Change-Id: I191fdc666616d1ddf718d2a0b1461b9b645af879
Reviewed-on: https://go-review.googlesource.com/c/tools/+/360836
Trust: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
2022-02-15 00:29:01 +00:00
aarzilli c6fca02004 godoc: handle type parameters correctly in LinkifyText
LinkifyText should not generate links to global declarations for
identifiers that are type parameters.

Because the syntactic resolver does not record the declaration for type
parameters declared in the method receiver (see
https://golang.org/issue/50956) a name lookup is used as a workaround.
This is fine here because it is only applied to undeclared indentifiers
and LinkifyText is only ever called on a single declaration at a time,
not on a full AST.

Updates golang/go#50717

Change-Id: I32f2203ce80c060ee18ca8b964a2d5fd80f41957
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382714
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Alessandro Arzilli <alessandro.arzilli@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Peter Weinberger <pjw@google.com>
2022-02-14 18:01:21 +00:00
Heschi Kreinick c0b9fb59f7 internal/lsp/analysis/undeclaredname: suppress impossible quick fixes
Reading the code and running the tests, it appears we only support quick
fixes for undeclared name errors inside function bodies. Don't offer
them in other places.

The specific situation raised was type constraints, so that's what I
tested even though the problem was much broader. Also add actual error
messages where we had empty strings.

Fixes golang/go#50935.

Change-Id: I8dadcb6e4301bf22cbe7fe5d66064aafeef02690
Reviewed-on: https://go-review.googlesource.com/c/tools/+/384117
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@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-09 19:35:26 +00:00
fzipp 9b156eeb91 internal/lsp/source: provide full documentation of builtin types
This change adds support for full documentation of builtin types in the
hover info, consisting of the type declaration, a link to pkg.go.dev,
and the text of the doc comments in the `builtin` pseudo-package.

Full documentation for builtin functions was already supported.
Removes the special case for the `error` interface, which is not needed
and didn't provide the full documentation anyway, only the type
declaration.

The code has to determine the parent ast.GenDecl (which holds the doc
comments) for the ast.TypeSpec of a builtin type.

Fixes golang/go#50196

Change-Id: I51a054cd7e864300ba2e51152311744b7bcf3e0c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/383614
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 Findley <rfindley@google.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-02-08 17:01:10 +00:00
Robert Findley caecc2b0ac internal/typeparams: add a generic form of types.AssignableTo
For some use-cases, it is helpful to compute predicates between
uninstantiated generic types.

This CL implements one such predicate for types.AssignableTo, a helper
GenericAssignableTo which reports if, for generic types V and T with the
same number of type parameters, all instantiations V[A_1, ..., A_N] are
assignable to the corresponding instantiation T[A_1, ..., A_N].

For #50887
For #50447

Change-Id: I7a0550fba05666bb2375d478d5390a123e09f556
Reviewed-on: https://go-review.googlesource.com/c/tools/+/383094
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-02-08 16:50:25 +00:00
Heschi Kreinick 164402db9d internal/lsp/cache: set types.Config.GoVersion
Set the language version from the controlling go.mod file's go version,
if any. Also verify that we properly surface a diagnostic if the version
is invalid.

I didn't add any quick fixes.

Fixes golang/go#50688.

Change-Id: Ic472502d1224a1decb5b989d51110b837020e998
Reviewed-on: https://go-review.googlesource.com/c/tools/+/383394
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@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-07 18:19:30 +00:00
Hana 6aaba7740f internal/lsp/debug: add go version to gopls version output
Add -json flag to output in JSON format.

Include the Go version info
  - go1.18: runtime/debug.BuildInfo.GoVersion
  - pre go1.18: runtime.Version

Restructure ServiceVersion so we embed info from
runtime/debug.BuildInfo. Instead of directly using
runtime/debug.BuildInfo, we use our own BuildInfo type.
That allows:
  for go1.17 or older versions, we can add GoVersion.
  for go1.18, we can drop MarshalText that prevents
  JSON encoding other languages and human can understand
  (golang/go#51026)

For golang/go#49783

Change-Id: Ia5ab50ce1f5e6c3a912654834785ecea7f5034e2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382274
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-02-07 15:39:03 +00:00
Heschi Kreinick 414ec9c3f0 internal/lsp: add ListImports
The VS Code extension uses information about imports to figure out
whether a given function is a Testify test. As of writing, it asks:
- Does the file import Testify?
- Does the package it's in do so?
To answer these questions, add ListImports, which tells you about the
packages imported by the current file, including their import name,
plus the import paths of all imports in the entire package.

I suspect the latter may be wrong in the presence of GOPATH vendoring,
but that should be a relatively rare situation at this point so I didn't
bother testing.

Fixes golang/go#40514.

Change-Id: I4c69e1db80dce6e594bdb595a81aade1ddec4d29
Reviewed-on: https://go-review.googlesource.com/c/tools/+/383354
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@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-04 22:09:29 +00:00
David Chase d55d8929fe gopls/doc: how to request a particular gopls w/ sublime text
I needed to do this to get a generics-capable version of gopls,
because sublime LSP downloads and installs its own.  Other
people may also need to do this, now or in the future, and it
was a pain to figure out the exact incantation.

Change-Id: I360b7ee9438a2c6588f55745aa1d6f3a47ddd2fc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382794
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@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-02-04 21:02:33 +00:00
Robert Findley cf66aec62b gopls: update coc.nvim documentation for using go.work
For golang/go#50955

Change-Id: Idab88d258ceab3312adccd97eb58ed64e5fb5053
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382242
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:04:20 +00:00
Robert Findley 597b165f5f internal/lsp/cache: use -workfile on 1.18
When using go 1.18 with go.work files, don't fake workspaces by creating
a workspace module: just run from the workspace root and pass -workfile.

For golang/go#44696

Change-Id: Iaa1979d26b1ce67c6e18e0bf26546a504069da8c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382241
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:03:59 +00:00
Robert Findley 8305295d5d gopls: recognize the go.work file type
For golang/go#50930

Change-Id: I5bae56853f1e913fccd559d2a553ced4200bcb35
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382237
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:03:20 +00:00
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