Commit Graph

6821 Commits

Author SHA1 Message Date
Suzy Mueller 2f04713366 gopls: fix out of bounds bug in extract
There was a bug where the code would try to access an out of bounds
index when trimming extra space and comments in extract. This change
also adds a regtest for extract.

Fixes golang/go#55271

Change-Id: I7da716a6a68a9678011abf15def47acdea0b33fe
Reviewed-on: https://go-review.googlesource.com/c/tools/+/432135
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-09-21 16:48:39 +00:00
Robert Findley 16b974289f go/analysis/passes/loopclosure: use go/types' object resolution
Object resolution in go/types is more accurate than the purely syntactic
object resolution in go/parser (for example, golang/go#45160), and spans
multiple files. Use it for more accurate diagnostics in the loopclosure
analyzer.

Change-Id: I2160876dd4b3fd83aa07a9da971f27c17d7d6043
Reviewed-on: https://go-review.googlesource.com/c/tools/+/432137
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2022-09-21 14:24:54 +00:00
Robert Findley 81a42f0a4f gopls/internal/lsp/tests: pass in a *testing.T to Data.Golden
Data.Golden is called from subtests: use the *testing.T from the caller,
so that we can get a more meaningful failure.

For golang/go#54845

Change-Id: I136df0c6a7a11bcf364b78ecac42ba2b51a15bb0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/431844
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-21 12:54:23 +00:00
Robert Findley 14462efca9 go/analysis/passes/loopclosure: experiment with checking t.Run+Parallel
Add experimental new logic to the loopclosure analyzer that checks for
access to loop variables from parallel subtests. For now, this is gated
behind an internal variable so that we may experiment with it without
yet affecting cmd/vet.

Add an internal/loopclosure command that enables the experimental new
check.

Change-Id: Ibf7e388a58a2b3e712e66e095d06612cf3ea918c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/430916
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2022-09-20 22:09:32 +00:00
cui fliter 00ae48efaf go/internal/pkgbits: replace os.SEEK_CUR with io.SeekCurrent
Change-Id: I68ee64ecc4e9ec3ec5894b878b64cc5611684dd2
GitHub-Last-Rev: 3092826e516c86367bffc799d0547b8f4667f21d
GitHub-Pull-Request: golang/tools#399
Reviewed-on: https://go-review.googlesource.com/c/tools/+/431995
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Hyang-Ah Hana Kim <hyangah@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-20 17:54:37 +00:00
Hana (Hyang-Ah) Kim 835bfdfb41 gopls: update x/vuln to pick fix for incorrect version suggestion
Fixed in https://go-review.git.corp.google.com/c/vuln/+/430684

Updates golang/go#54913

Change-Id: I1932a09bdd2a2192c6b61458cef28978c2e7f660
Reviewed-on: https://go-review.googlesource.com/c/tools/+/432076
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-09-20 17:52:05 +00:00
Alan Donovan 6782af031e gopls/internal/lsp/source: clarify qualifiedObject
Clarify documentation around qualifiedObject and
its field invariants.
(Initially I tried to delete it but it's not so easy.)

Also, hoist KnownPackages et al outside of loop over
qualifiedIdentifiers in implementations() to avoid unnecessary
recomputation.

Change-Id: Idf087634b918a2277eabf8bbab2fdf49a8fc946c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/431839
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Alan Donovan <adonovan@google.com>
2022-09-20 16:27:24 +00:00
Robert Findley f901623876 gopls/internal/lsp: suppress noisy log output in tests
Disable logging for lsp tests: logs are not scoped to the failing test
and are therefore misleading.

For golang/go#54845

Change-Id: I232e4cfc114382121923e8e697452007793ec3c9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/431843
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
2022-09-20 12:41:02 +00:00
Robert Findley df2eb9381f gopls/test: fix erroneously skipped tests, remove redundant cmd tests
When code was moved to the golang.org/x/tools/gopls module, the
gopls/test package tests we silently skipped, because of logic that
skipped the tests if the testdata directory was not found. Narrow that
check to only skip tests on android, which is where we expect testdata
to be missing.

Also, now that gopls code lives in the gopls module, there is little
reason to have two copies of the command-line tests. Delete
gopls/internal/lsp/cmd/cmd_test.go.

Change-Id: I6d57244dd77a983b1f83c1cf653d5345e4fa0434
Reviewed-on: https://go-review.googlesource.com/c/tools/+/431842
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2022-09-20 12:40:42 +00:00
Suzy Mueller 1578244678 gopls: set codelensProvider in initialize response
gopls needs to register that it is a codelensProvider.

Fixes golang/go#55155

Change-Id: I91d6eb320871386175b2fb95ab5e9bf935a84014
Reviewed-on: https://go-review.googlesource.com/c/tools/+/431837
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
2022-09-19 18:40:20 +00:00
Suzy Mueller fdf581fdab internal/lsp: allow extract func ranges to begin/end with comments
CanExtract strips of the whitespace on either end of the range in
order to get an exact range to extract to function. We can do the
same thing for comments by moving adjusting the range if the start
or end positions contain the position.

Updates golang/go#37170
Fixes golang/go#54816

Change-Id: I3508c822434400f084a273730380c89611803e97
Reviewed-on: https://go-review.googlesource.com/c/tools/+/351989
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-19 18:18:22 +00:00
Robert Findley b256f1f4a1 gopls/internal/lsp/cache: remove distracting "safe trimming" log
This log is noisy and of little value, often confusing users. Remove it.

Updates golang/go#51947

Change-Id: I2b2dff8383de52467bf3953d3efda4e6d4b792dd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/431836
Reviewed-by: Heschi Kreinick <heschi@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
2022-09-19 18:14:27 +00:00
cui fliter 0e011a0e6c all: use constant to avoid repeated definitions
Change-Id: I9e0a167cc3a9772412f3ec809eeb4720ae331c98
GitHub-Last-Rev: 4a909d88f4ddb99195de6fdfee040d883236c2da
GitHub-Pull-Request: golang/tools#398
Reviewed-on: https://go-review.googlesource.com/c/tools/+/431637
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-09-19 15:32:23 +00:00
Robert Findley 4d18923f06 gopls/internal/fake: sort edits by both start and end position
When processing edits, they must be non-overlapping but they may be
adjacent: we must allow for insertions adjacent to replacements, e.g. an
edit of 3:1-3:1 followed by an edit of 3:1-3:15. Achieve this in the
fake editor by sorting edits by end position after start position.

Longer term, we should eliminate this ad-hoc editing in favor of
diff.ApplyEdit.

Change-Id: I72a252952585d0a652d97287486aa61c167db485
Reviewed-on: https://go-review.googlesource.com/c/tools/+/431219
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dylan Le <dungtuanle@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
2022-09-17 00:45:41 +00:00
Peter Weinbergr 45ad958c90 gopls/internal/lsp/protocol: fix json tags and indirect some zero values
Some of the json tags, especially for constructed structs, had improper
json tags (e.g., Range *Range `json:"Range"`, not `json:"range"). These
now start with lower-case letters.

Also, an optional field which is a struct type could be either
F FsType `json:"f,omitempty"`, or
F *FsType `json:"f,omitempty".

The second is generally better, as zero values should not be sent,
but there are many cases where the existing
code needs the first, to avoid allocations.

That is, if we're sending an empty optional field, there should be a *,
but if we're intializing a complicated structure (x.A.B.C.D = true, with
B and C optional) existing code wants no *. (These two cases could
conflict, and then the existing code would have to be changed.)

Fixes golang/go#55099

Change-Id: I947a69322bcddf4c963d34662b72b464b738d17c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/431218
Run-TryBot: Peter Weinberger <pjw@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-09-16 20:08:00 +00:00
Robert Findley a61f20e1aa internal/gocommand: tweak debugging for hanging go commands
Add a TODO and wait for a shorter period of time following Kill, per
post-submit advice from bcmills on CL 424075.

For golang/go#54461

Change-Id: Ia0e388c0119660844dad32629ebca4f122fded12
Reviewed-on: https://go-review.googlesource.com/c/tools/+/431075
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-09-15 19:41:03 +00:00
Peter Weinbergr cdd69867e3 gopls/tsprotocol: make Disabled in CodeAction optional
The new LSP stubs were returning a "disabled" struct in CodeActions,
which is wrong, and this CL fixes.

Tested by hand.

Fixes golang/go#55080

Change-Id: Id38df18f1e3f20ef2aa1cb1adfe96dacacad9ad6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/431216
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-09-15 19:17:13 +00:00
Robert Findley 0398b3de2b internal/gocommand: add instrumentation for hanging go commands
When a go command hangs during gopls regression tests, print out
additional information about processes and file descriptors.

For golang/go#54461

Change-Id: I92aa4665e9056d15a274c154fce2783bed79718e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/424075
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-15 14:14:04 +00:00
Peter Weinberger 9250e22aa3 internal/lsp: latest version of LSP stubs
This CL updates the LSP to 3.17.0. It is a DANGEROUS CL as the stubs
are being generated by Go code reading vscode's language independent
description of the protocol (in metaMode.json in the vscode-languageserver-node
repository.)

Some of the union types in the protocol have Go types with names containing  'Or'.
These types have custom marshaling and unmarshaling code.

Embedded structures in the protocol are broken out as their own
types, with names constructed from the context in which they occur.

The natural output has been modified to minimize the number of changes
needed for gopls. (e.g., Workspace6Gn is preserved for compatibility.0
Thus, many types that are union types in the LSP description have been replaced by the
types gopls already uses.

Updates golang/go#52969

Change-Id: I16f6d877215155ac9e782b0f5bcbdab3f1aa2593
Reviewed-on: https://go-review.googlesource.com/c/tools/+/424214
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Peter Weinberger <pjw@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-09-13 15:21:19 +00:00
Robert Findley ec743893cd gopls/internal/lsp/source: make "chatty" diagnostics the default
This CL changes the default behavior of gopls to always publish
diagnostics for new file versions. In practice, this avoids stale
diagnostics in multiple LSP clients (golang/go#54983 has more details).

After this change, TestDownloadDeps was failing because it asserted on
the non-existence of published diagnostics. Update the test to treat an
empty diagnostic set the same as an unreceived diagnostic set.

Fixes golang/go#54983

Change-Id: I41ed2f859b748e14585e7feb53702d3f38dcd599
Reviewed-on: https://go-review.googlesource.com/c/tools/+/429935
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2022-09-12 18:14:22 +00:00
Suzy Mueller 7e129ca5ef gopls: add codelens to reset upgrade diagnostics
This clears the diagnostics that were added by the `Check for
upgrades` codelens for the given go.mod file. The diagnostic
source for the diagnostics from `Check for upgrades` is now
modCheckUpgradesSource instead of modSource in order to allow
us to easily clear these diagnostics.

Fixes golang/go#54065

Change-Id: I7c0824ce1fdfcf2a73ec83342501ceed82fc519f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/426016
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
2022-09-12 15:41:56 +00:00
Hana (Hyang-Ah) Kim a81fce34b3 gopls: run go mod tidy -compat=1.16
golang.org/x/text and golang.org/x/sync are direct dependencies.

Change-Id: I8fea3ddbbf5e2917e45a7a9a5b1d12310fe62c83
Reviewed-on: https://go-review.googlesource.com/c/tools/+/430275
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
2022-09-12 13:57:37 +00:00
Hana (Hyang-Ah) Kim a8b9ed3e93 gopls/internal/lsp/source: remove Govulncheck from Hooks
Now lsp packages are moved to the gopls module where the vulncheck
implementation exists. We no longer need to inject govulncheck
through the hook.

Change-Id: Ia627f1abe4c626d254d3e72b778535d6cb1ab41e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/429938
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-09-12 13:57:24 +00:00
Hana (Hyang-Ah) Kim 678efe0184 gopls/internal/lsp/cmd: fix vulncheck error handling
Fix 1 - print usage info only when appropriate:

tool.CommandLineError is a special error that makes a command
exits with full usage documentation. When Govulncheck hook runs and
fails, it's unlikely the failure was from command line misuse
and the extra usage doc will distract users from the root cause.
Let's stop that by returning a plain error.

Fix 2 - stop printing package loading errors twice:

Package loading error was printed by the logger in gopls/internal/vulncheck.cmd
and once more by the gopls command line handler. Print it once.

For testing, added back the replace statement to go.mod.
We will update go.mod back after this commit is merged.

Change-Id: Ifaf569a31bbbc84d7b84e1b6d90a8fa0b27ac758
Reviewed-on: https://go-review.googlesource.com/c/tools/+/429515
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/tools/+/429937
2022-09-12 13:21:00 +00:00
Tim King e71c338beb go/ssa/ssautil: initialize info when there is syntax
Only initialize *types.Info when there are []*ast.Files available.

Previously, when packages x and z, where x imports y and y imports z,
are loaded with packages.LoadSyntax and built with ssautil.Packages,
then package y will have *types.Info but no files.
If y has any globals initialized from a func variable, the bodies
of the function literals did not have type information and failed
to build.

Fixes golang/go#53604

Change-Id: I3cce608d6a127ac44b65947b68cf0d748fc2dfc6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/422639
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2022-09-11 21:08:46 +00:00
Tim King 0eebaabce7 go/analysis: allow for identical SuggestedFixes
Stop treating identical SuggestedFixes as overlapping text edits.
Packages can be loaded in multiple ways due to testing, e.g.
"p" and "p [p.test]". Currently SuggestedFixes from both are
considered overlapping and so are not applied.

Updates applyFixes() to report errors in more situations.

Fixes golang/go#54740

Change-Id: I73acb3b73d88535144cfae5161faabb0615a1774
Reviewed-on: https://go-review.googlesource.com/c/tools/+/426734
Reviewed-by: Abirdcfly Abirdcfly <fp544037857@gmail.com>
Run-TryBot: Tim King <taking@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
2022-09-09 18:15:02 +00:00
Robert Findley eeaf4eb24c internal/lsp/fake: add rename file support for testing
This CL implements the fake.Editor.RenameFile method, which mimic's the
behavior of VS Code when renaming files. Specifically:
- open buffers affected by the renaming are closed, and then reopened
  with new URIs
- files are moved on disk
- didChangeWatchedFile notifications are sent

Along the way, add missing comments and fix one place where the editor
mutex was held while sending notifications (in Editor.CreateBuffer).
Generally, the editor should not hold any mutex while making a remote
call.

For golang/go#41567

Change-Id: I2abfa846e923de566a21c096502a68f125e7e671
Reviewed-on: https://go-review.googlesource.com/c/tools/+/427903
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-09 15:30:36 +00:00
cuiweixie 4754f75dad go/analysis/passes/copylock: modify match pattern to satisfy change sync.Once.done to atomic.Bool
Change-Id: I387c946736d76613c83d2363cb85cbc038056e0c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/428986
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
2022-09-08 19:07:57 +00:00
Robert Findley a63075185d x/tools: update go.mod following moving LSP code to x/tools/gopls
For golang/go#54509

Change-Id: I1c3cb834e7216bde11ebd86654ae4dbce02d655e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/429216
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
2022-09-07 22:05:45 +00:00
Robert Griesemer 308e02cdee x/tools/go/ssa: disable slice-to-array test
CL 428938 implements slice to array conversions in the type checkers,
per accepted proposal issue golang/go#46505. The disabled test was
expected to fail, but it won't fail anymore for Go 1.20 and higher.
Disable it for now (and track it in golang/go#54822) so we can make
progress with CL 428938.

For golang/go#46505.
For golang/go#54822.

Change-Id: I87fc78dccaa2bf1517cf875fec97855e360d0f25
Reviewed-on: https://go-review.googlesource.com/c/tools/+/429295
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tim King <taking@google.com>
2022-09-07 21:28:53 +00:00
Robert Findley 3ee171058f gopls/doc: update stale documentation and improve link names
Following up on comments from CL 428595 and CL 426796, improve links to
'here', and update a stale comment on gopls' code location.

Updates golang/go#54509

Change-Id: Ie0e04b01b6e7193294fb9c39a809cee1a5b981c5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/429215
Reviewed-by: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
2022-09-07 18:17:13 +00:00
cui fliter 5f27e05096 all: remove redundant type conversion
Change-Id: Iffb04ebd6b4afbe1a13b96b7e7469ec3b3e3380f
GitHub-Last-Rev: 6682724eb7cce8e3194650d28cb5eebd78e14700
GitHub-Pull-Request: golang/tools#396
Reviewed-on: https://go-review.googlesource.com/c/tools/+/428980
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-09-07 17:33:19 +00:00
Robert Findley b15dac2b88 gopls: migrate internal/lsp to gopls/internal/lsp
This CL was created using the following commands:

    ./gopls/internal/migrate.sh
    git add .
    git codereview gofmt

For golang/go#54509

Change-Id: Iceeec602748a5e6f609c3ceda8d19157e5c94009
Reviewed-on: https://go-review.googlesource.com/c/tools/+/426796
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-07 16:44:44 +00:00
Timon Wong dd1bab2d98 go/analysis/passes/printf: fix panic parsing argument index
Fixes golang/go#54828

Change-Id: I516dc83230f6bc96b0ff21f3bbae702f1511e5b0
GitHub-Last-Rev: b26f46a2df820d4862b7c81200c86551b84719fa
GitHub-Pull-Request: golang/tools#395
Reviewed-on: https://go-review.googlesource.com/c/tools/+/426875
Auto-Submit: Tim King <taking@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Tim King <taking@google.com>
Reviewed-by: Tim King <taking@google.com>
2022-09-07 16:01:16 +00:00
Abirdcfly bac5507b3e go/analysis/internal/checker: make applyFixes work from the first character
Make sure modifying the first character of the file takes effect.

Fixes golang/go#54774

Change-Id: Ib77231b9bd15f35fe50b2c2d6c7ea260c9c3cba5
GitHub-Last-Rev: b58bbdf4c247b22947223b157a1d36ecc856c652
GitHub-Pull-Request: golang/tools#393
Reviewed-on: https://go-review.googlesource.com/c/tools/+/426654
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Tim King <taking@google.com>
2022-09-07 15:31:31 +00:00
Robert Findley c1dd25e80b gopls/internal/migrate.sh: a script to migrate internal/lsp to gopls/
Add a script that does the migration of the internal/lsp directory to
gopls/internal/lsp. This is done in a separate CL so that in-progress
CLs can rebase on top of *this CL*, run this script, and then rebase to
tip.

For golang/go#54509

Change-Id: I6f529c1e4ba29b4d88dc26278d54a055f1ef212e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/426795
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
2022-09-07 14:10:36 +00:00
Peter Weinberger 83d76192b2 gopls : add a mention of staticcheck to settings documentation
Fixes golang/go#52874

Change-Id: I04664154d68e31f48234c13aefe8470b09f0413e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/428595
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Peter Weinberger <pjw@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-09-06 14:55:05 +00:00
Dylan Le d815cba582 internal/lsp: update LSP protocol for WorkspaceEdit
Change DocumentChanges field type from []TextDocumentEdit to []DocumentChanges. DocumentChanges is a union type of TextDocumentEdit and RenameFile used for renaming package feature. It distinguishes a renaming directory ops from a text document edit ops.

For golang/go#41567

Change-Id: I25d106b34821effc53b712800f7175248e59ee25
Reviewed-on: https://go-review.googlesource.com/c/tools/+/427538
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Dylan Le <dungtuanle@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-02 19:58:35 +00:00
Robert Griesemer 6a585a2bf9 x/tools/internal/typeparams: use regexp to match wanted result
CL 410955 changes printing of unions which breaks two typeparams tests.
Use regexp matching and adjust the wanted results accordingly.

For golang/go#53279.
For golang/go#54822.

Change-Id: I7060df47d36ce3069570237dafff024aaad637a5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/428055
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
2022-09-02 19:06:05 +00:00
Abirdcfly be9eab19b4 go/analysis/passes/inspect: fix example return
Change-Id: I9e248c45078d36ded9c6008e2b7e2c8bf8586df1
GitHub-Last-Rev: 33900677c6118060af36c6ec16db5b937912ae61
GitHub-Pull-Request: golang/tools#390
Reviewed-on: https://go-review.googlesource.com/c/tools/+/425204
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Tim King <taking@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-09-02 18:39:41 +00:00
Robert Griesemer 5ba85415fa x/tools/internal/lsp/source: disable some tests for std lib changes
CL 410955 changes printing of unions which breaks a few lsp tests.
Disable them for now so we can submit CL 410955.

For golang/go#53279.
For golang/go#54822.

Change-Id: I54ff99a4f5530181a39557b6b62e776af082c28d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/428054
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
2022-09-02 18:17:25 +00:00
Hana (Hyang-Ah) Kim eb8352e307 gopls/internal/govulncheck: sync x/vuln@62b0186
VulnDB OSV schema was changed recently
  https://go-review.googlesource.com/c/vulndb/+/424895
to fix the misinterpretation of 'affected.package.name',
and the database entries were repopulated with the new schema.
We need to update the client library to pick up the change.
We also need to update the fake vulndb entries used in tests.

gopls/regtest/misc/testdata/vulndb was copied from
  golang.org/x/vuln/cmd/govulncheck/testdata/vulndb @ 62b0186
(the version updated in cl/424895)

Also reverse golang.org/cl/425183 which includes the position
information in the SummarizeCallStack result. Like in govulncheck -v,
the position info is already available in the callstack, thus
this is unnecessary for us. Since x/vuln is currently frozen
until the preview release, revert it from gopls/internal/vulncheck.

Ran go mod tidy -compat=1.16; otherwise, the transitive dependency
on github.com/client9/misspell from golang.org/x/vuln breaks go1.16
build.

Updated copy.sh script to copy x/vuln/internal/semver package
(golang/go#54401) and add the build tags back to all go files.
Gopls's builder builds&tests packages with old go versions,
so we still need go1.18 build tag.

Fixes golang/go#54818

Change-Id: I37770d698082378656a7988d3412a4ca2196ca7b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/427542
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2022-09-02 15:10:33 +00:00
Robert Findley 655abda1c0 gopls/internal/regtest: TestEditGoDirectiveWorkspace should fail eagerly
TestEditGoDirectiveWorkspace did an unconditional wait on expected
diagnostics. Turn this into OnceMet conditions that fail as soon as the
relevant diagnostic pass is complete.

Fixes golang/go#54825

Change-Id: I2654682108561dd60546a589ebd1c6aa2ebaff1f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/427543
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
2022-09-02 14:20:31 +00:00
Robert Griesemer 33c1ddd5a8 tools/gopls/internal/regtest/diagnostics: handle new error message
Pending CL 426477 changes go/types error messages containing the phrase:

	type parameters require

to:

	type parameter requires

Adjust diagnostics test accordingly (note that regular expressions are
currently not supported).

For golang/go#54511.

Change-Id: I561cb940a41cb6cc949c44e0d4b8f009336a46cd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/427736
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-09-02 00:49:50 +00:00
Robert Griesemer 40cfafff02 x/tools/internal/lsp/source: disable some tests for std lib changes
CL 425716 changes parser behavior for incorrect code (it is more
lenient) which breaks a few lsp tests. Disable them for now so we
can submit CL 425716.

For golang/go#54511.
For golang/go#54822.

Change-Id: I00fa67e29628137f3e4e44c38e92094ea581a61b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/427654
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-09-01 22:03:33 +00:00
Brian Pursley f16be35d92 internal/lsp/source: add functions to type hover output
Add functions to the output when hovering over a type.

Fixes golang/go#54008

Change-Id: Ia0a7b5a878c3d63c4bbc549f003c45592db1c135
Reviewed-on: https://go-review.googlesource.com/c/tools/+/420714
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-01 17:52:14 +00:00
Robert Findley dfc8d49339 internal/lsp/testdata: fix diagnostics checksum
Fix an incorrect diagnostics checksum causing builder failures.

Change-Id: Ief4f9edd6acbf8d42eaf1109ec6ddc0085f20b05
Reviewed-on: https://go-review.googlesource.com/c/tools/+/427536
Auto-Submit: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Dylan Le <dungtuanle@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-09-01 17:30:47 +00:00
Alan Donovan 6c10975b72 internal/lsp/cache: honor RunDespiteErrors=false
This change prevents analysis from running on a package containing
any kind of error unless the analyzer has indicated that it is robust.
This is presumed to be the cause of several panics in production.

And a test.

Updates golang/go#54762

Change-Id: I9327e18ef8d7773c943ea45fc786991188358131
Reviewed-on: https://go-review.googlesource.com/c/tools/+/426803
Run-TryBot: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-09-01 15:27:30 +00:00
Robert Griesemer 49ab44de90 x/tools/internal/lsp: re-enable a test with adjusted error message
This is a follow-up on CL 425497. Must be submitted after CL 425007.

For golang/go#54511.

Change-Id: Ice9c1c62b911efa8efa20ea295bf313aabe8c5bb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/425594
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2022-09-01 03:24:42 +00:00
Robert Findley 550e1f5a55 internal/lsp/tests: use a shorter module path for test data
While moving internal/lsp to gopls/internal/lsp, we discovered that
we're bumping up against a command line length limit on windows. Use an
arbitrary shorter module path to avoid this, for now.

Updates golang/go#54800
Updates golang/go#54509

Change-Id: I7be07da29a769c1ce7c31cbbd374ca47b0944132
Reviewed-on: https://go-review.googlesource.com/c/tools/+/426801
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
2022-08-31 21:10:26 +00:00