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

8454 Коммитов

Автор SHA1 Сообщение Дата
Dmitri Shuralyov 2ba7cf9616 internal/imports: remove obsolete go:generate directive
CL 567837 deleted mkstdlib.go (a generator) and zstdlib.go (its output).

For golang/go#46136.
For golang/go#38706.

Change-Id: If5623e3ab014c2fee63b1d058c726ea5acb06aa2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/571276
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-03-19 16:30:57 +00:00
Zxilly 0fb9b7b709 gopls: use slices package for reverse slice
slices has been supported in go1.21 and go1.22

Fixes golang/go#66222

Change-Id: I7b319e649632a713200dcaabd1e68d1f01e1b2f2
GitHub-Last-Rev: fc1d59d86a
GitHub-Pull-Request: golang/tools#484
Reviewed-on: https://go-review.googlesource.com/c/tools/+/572116
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-03-19 15:15:34 +00:00
Robert Findley c21ae4cabc gopls/internal/golang: don't suggest removeparam when there are errors
Update the canRemoveParameter logic to reflect that we don't try to
remove parameters when there are parse or type errors.

Change-Id: Ia8239a383b56763d100c69c9a3633c87025b81cf
Reviewed-on: https://go-review.googlesource.com/c/tools/+/572297
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-03-18 20:56:23 +00:00
Robert Findley f3fcceee06 gopls/internal/golang: support removing unused parameters from methods
Make a minimal change to the removeparam algorithm to support removing
unused parameters of methods.

This doesn't address the problem of expanding the set of signatures or
calls based on interface satisfaction constraints: that is really a
separate concern, which also affects method renaming (golang/go#58461).
Were we to have a more general solution to that problem, it would be
relatively straightforward to also expand the change signature
algorithm.

For golang/go#38028

Change-Id: I296cb1f828f07d841c83b1fd33593ccd2fee3539
Reviewed-on: https://go-review.googlesource.com/c/tools/+/572296
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-18 20:56:16 +00:00
Robert Findley 2d517d51b8 gopls/internal/golang: fix build breakage due to semantic conflict
Unbreak the x/tools build dashboard due to a semantic conflict between
CL 572475 and CL 571215.

Change-Id: I8ce1308ee99e75aa7cf8f7bd1d8b1dedcb845f4d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/572515
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-18 20:31:43 +00:00
Alan Donovan 6af02955c9 go/analysis/passes/stdversion: publish
This CL moves the stdversion analyzer out of gopls,
into the exported analyzer tree, whence it will be
vendored into cmd/vet in a follow-up.

Updates golang/go#46136

Change-Id: I039ef78ecdcfd6bc64d5b089017a9b8635cf9aa5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/572035
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-18 20:14:13 +00:00
Alan Donovan 8669bfccbe gopls/internal/server: add "View package documentation" code action
This CL adds a "View package documentation" code action to any
selection in a Go source file. Its command has two effects:

1) to start a web server associated with the current LSP
   server, with coupled lifetimes, and register a handler
   to serve the package documentation; and

2) to direct the client to open a browser page
   showing the package documentation for the selection.

The server is a minimal imitation of pkg.go.dev,
working off the cache.Package representation. This means
we can display doc markup even for unsaved editor buffers,
and show type-derived information such as method sets
of each type.

Clicking through to the source--which on pkg.go.dev goes
to cs.opensource.google--causes the client editor to
navigate directly to the source file, using the magic
of showDocument requests.

The web server is secure in that all its endpoint URLs contain
an unguessable secret, so a local process belonging to
a different user can't access source code by port scanning.

The CL includes a test that
(a) the webserver content reflects edits (even unsaved)
    in the source buffers, and
(b) that "clicking" through the source link causes
    the server to navigate the client editor to the
    correct source location.

A couple of tests that asserted "no code actions" needed
to be tweaked, as now there is always at least one
code action in any Go source file.

Change-Id: I2fe1f97e4e2b0b15cff6a4feb66501fce349b97d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/571215
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-03-18 19:36:00 +00:00
Dmitri Shuralyov 56284432e0 gopls/internal/test/marker: remove runtime.GOROOT from format.txt case
The runtime.GOROOT function is about to be marked as deprecated, which
will generate a diagnostic that isn't expected in format.txt test case.
Pick another hopefully somewhat future-proof identifier, since dealing
with this doesn't seem to be in scope of this test case.

For golang/go#51473.

Change-Id: I54d7ed0b43860bcd41938328211797a0cdd60e36
Reviewed-on: https://go-review.googlesource.com/c/tools/+/564275
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-03-18 19:15:13 +00:00
Robert Findley 6d9ecf2227 gopls/internal/cache: rename methods on Package
Rename methods on cache.Package to eliminate unnecessary "Get" prefixes.
Also rename pkg.go to package.go.

Change-Id: I42f2fa7a18a5973a53af93c63b48c7db19cba3b2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/572475
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-03-18 17:50:33 +00:00
Alan Donovan 29d17a052c go/cfg: publish (*CFG).Dot method
The new method formats the graph in the syntax used by
the 'dot' command from https://graphviz.org/.

Fixes golang/go#65754

Change-Id: Icf696419070e19b2f2236ac1e4aaa09323c565de
Reviewed-on: https://go-review.googlesource.com/c/tools/+/572016
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
2024-03-16 22:28:19 +00:00
Ihar Suvorau 03f7b7be3e x/tools/go/packages: fix Load's "argument list too long" error
The current implementation doesn't assume any limit on the amount of
patterns passed to Load which breaks it when called on large codebases.
Different platforms have implemented different values for ARG_MAX,
https://www.in-ulm.de/~mascheck/various/argmax/#results,
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html,
https://devblogs.microsoft.com/oldnewthing/20031210-00/?p=41553.

In this fix, we use a conservative estimation of ARG_MAX (32767)
that would suit all the supported platforms, subtracted by an approx.
length of env on a typical machine (16384). We use this value to split
the provided patterns into chunks to run the underlying driver on chunks
instead of the whole patterns slice.

Fixes golang/go#36909

Change-Id: I7c462c1e905b1f95013afa2b0ce2aa0a435125dc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/550477
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2024-03-15 16:51:31 +00:00
Robert Findley 67e856beab gopls: fix test failures due to quoting of names in go/types errors
Starting soon, go/types will quote some user defined names in error
messages as `a'. Update tests to be tolerant of the new syntax.

Notably, logic in the unusedvariable analyzer which extracts the
variable name had to be updated.

Change-Id: I091ab2af9b5ed82aa7eacad8f4a9405f34fcded7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/571517
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2024-03-14 21:55:05 +00:00
Peter Weinberger e25671485f gopls: repair premature commit of 562248
I clicked the wrong button (twice) before including
the last round of changes. This CL adds a necessary
copyright notice, and adjusts init() and comments in
a test file.

Change-Id: Ibf5d8e4d071fb571eab910902f0bc22009f2b81c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/571755
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-03-14 17:37:39 +00:00
Peter Weinberger 887727a343 gopls: Measure the efficacy of completions
This CL introduces code to count how often proposed completions are accepted.

The results of the latest completion request are stored and compared
with the next DidChange notification. If the change is at the same
position, more than one character long, and matches a completion
item, the code counts the completion as accepted.

If, for some reason, DidChange returns multiple changes, only the
first is checked.

If the whole file is replaced there is no check for using any
proposed completion.

The test does not exercise the multi-change counter.

Change-Id: I08e9e39f651e4975a86c2dda9f6f5ceab7787e53
Reviewed-on: https://go-review.googlesource.com/c/tools/+/562248
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-14 16:39:33 +00:00
Rob Findley ca94c9663f gopls/internal/server: update telemetry prompt link
Now that go.dev/doc/telemetry exists, use it as a better link for
information about go telemetry.

For golang/go#63883

Change-Id: Ibe561c435e648b324a5ac444a8aade953354e92b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/570677
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-11 20:13:56 +00:00
Rob Findley d4b1eff55d gopls/internal/golang: fix crash in package references
Fix a crash found via telemetry, which may be encountered when finding
references for a package where one of the package files lacks a valid
name.

Fixes golang/go#66250

Change-Id: Ifca9b6b7ab2ab8181b70e97d343fa2b072e866eb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/570676
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-03-11 18:07:46 +00:00
Rob Findley f89da538c8 gopls/internal/server: fix crash in SignatureHelp
Fix a crash when Snapshot.fileOf fails, due to e.g. context
cancellation. The defer of release should only occur after the error is
checked. Unfortunately, this is very hard to test since it likely occurs
only due to races.

This is our first bug found completely via automated crash reporting.

Fixes golang/go#66090

Change-Id: I7c22b5c2d1a0115718cd4bf2b84c31cc38a891ec
Reviewed-on: https://go-review.googlesource.com/c/tools/+/570675
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-11 17:33:29 +00:00
Alan Donovan 176e895eb1 gopls/internal/analysis/stdversion: suppress before go1.21
This change causes the stdversion checker not to report
any diagnostics in modules with go versons before go1.21,
because the semantics of the go declaration were not
clearly defined to correspond to toolchain requirements
at that point. Also, those Go versions are now unsupported,
so reporting diagnostics just creates unnecessary churn.

Updates golang/go#46136

Change-Id: I323f704c4d4f1f0fe5fc8b5680824bc07d3c4112
Reviewed-on: https://go-review.googlesource.com/c/tools/+/570140
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-08 23:49:09 +00:00
Alan Donovan c1eaf76c37 gopls/internal/analysis/stdversion: set RunDespiteErrors
This change enables RunDespiteErrors, after auditing the code.
This should give more timely feedback while editing.

Also, it moves the vet/gopls common code (DisallowedSymbols)
to typesinternal.TooNewStdSymbols, out of the gopls module,
in anticipation of adding this analyzer to vet.

Updates golang/go#46136

Change-Id: I8d742bf543c9146376d43ae94f7adae3b453e471
Reviewed-on: https://go-review.googlesource.com/c/tools/+/570138
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-03-08 23:48:57 +00:00
Alan Donovan c67485cfa4 gopls/internal/golang/completion: honor std symbol versions (imported)
This change is the counterpart to CL 569435 for completions
in imported packages.

Updates golang/go#46136

Change-Id: I57011897c395d37a89a8e3a99e8c3511de017ad3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/569796
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-03-08 23:48:51 +00:00
Alan Donovan 1f580da078 cmd/guru: delete it
RIP guru, Go's LSP server before LSP was invented.

Fixes golang/go#65880

Change-Id: I75adef368e6e940c3b6dfc0ca06ad38ba0cf3656
Reviewed-on: https://go-review.googlesource.com/c/tools/+/569882
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-08 20:35:12 +00:00
Alan Donovan c6563ca60f cmd/guru: remove replace directive
Updates golang/go#65880

Change-Id: Icb45d94bd2ef0864ab054e76a6aa651b269e2ec5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/570139
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-03-08 19:54:13 +00:00
Robert Findley c1789339c5 gopls/internal/server: set -mod=readonly when checking for upgrades
When a vendor directory is present, we must explicitly use -mod=readonly
to query upgrades with `go list`. This was broken by the fixes for
workspace vendoring, which removed the `-mod` flag in most usage of the
gocommand package.

Fixes golang/go#66055

Change-Id: I29efb617a8fe56e9752dc088dc5ea884f1cefb86
Reviewed-on: https://go-review.googlesource.com/c/tools/+/569877
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-03-08 17:07:11 +00:00
Alan Donovan 9e530fc6f3 cmd/guru: carve out a separate module
This is the first step of deleting guru.

Updates golang/go#65880

Change-Id: Id33729265825f5557a47a5c571b2ae0e2d58336a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/570136
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-03-08 16:29:34 +00:00
Alan Donovan 9b64301ea6 gopls/internal/cache: avoid go/types panic on version "go1.2.3"
This change fixes a gopls panic caused by giving go/types@go.1.20
a Go version string with three components, e.g. go1.2.3.

Unfortunately this is hard to write a test for, since it requires
building gopls with go1.20 and running it with a go1.21 toolchain.

Fixes golang/go#66195

Change-Id: I09257e6ded69568812b367ee80cafea30add93d3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/570135
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-03-08 16:23:50 +00:00
Rob Findley 93c0ca5673 gopls/internal/cache: fix spurious diagnostics in multi-root workspaces
In golang/go#66145, users reported spurious import errors in multi-root
workspaces. The problem was related to scenarios where module A had a
local replace of module B, and the user opened a file F in module B that
wasn't in the forward dependencies of module A. In this case, if the
View of module A tried to load F, it would get real packages (not
command-line-arguments), but due to module graph pruning the View of
module A would not have access to the full set of dependencies for
module B, resulting in the potential for import errors. Even this would
not be a problem, as long as the package that module A loaded for F was
not considered a 'workspace' package.

Unfortunately a couple of incorrect heuristics in gopls added along with
the zero-config work of gopls@v0.15.0 allowed us to diagnose these
broken packages:

1. In resolveImportGraph, we called MetadataForFile for each overlay. As
   a result, the import graph optimization caused gopls to attempt
   loading packages for each open file, for each View. It was wrong for
   an optimization to have this side effect.
2. In golang/go#65801, we observed that it was inconsistent to diagnose
   changed packages independent of whether they're workspace packages.
   To fix that, I made all open packages workspace packages. It was
   probably wrong for the set of workspace packages to depend on open
   files. To summarize a rather long philosophical digression: open
   files should determine Views, not packages.

Fixing either one of these incorrect heuristics would have prevented
golang/go#66145. In this CL, we fix (2) by building the import graph
based on existing metadata, without triggering an additional load.

For (1), we check IsWorkspacePackage in diagnoseChangedFiles to enforce
consistency in the set of diagnosed packages. It would be nice to also
remove the heuristic that "all open packages are workspace packages",
but we can't do that yet as it would mean no diagnostics for files
outside the workspace, after e.g. jumping to definition. A TODO is left
to address this another day, when we can be less conservative.

Fixes golang/go#66145

Change-Id: Ic4cf2bbbb515b6ea0df24b8e6e46c725b82b4779
Reviewed-on: https://go-review.googlesource.com/c/tools/+/569836
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-03-08 15:33:16 +00:00
Alan Donovan 31f056a488 gopls/internal/cache: add assertions for telemetry crash
Updates golang/go#64547

Change-Id: I35b2477b8f6182bf6774095f18726104227a2fcd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/569935
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-03-08 15:27:43 +00:00
John Dethridge 656fcde9b8 go/callgraph/vta: use core type for channels
When adding edges to the type graph for channel operations, we need the
*types.Chan object for the channel's type.  The underlying type of a
channel may only be a type parameter, so use the core type instead to
get the *types.Chan.

Change-Id: I08078dbbb480363a372024161f0efb72a54c36a9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/568735
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Tim King <taking@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-07 22:04:10 +00:00
Alan Donovan b3a5e0bd0d gopls/internal/golang/completion: honor std symbol versions (unimported)
This change causes the imports package to return not just
lists of symbol names, but stdlib.Symbol structures, and
causes gopls to use them to filter candidates based on
the Go version of the requesting file.

This filtering is not applied to imported completions,
or to methods of unimported types (which apparently
we don't complete at all, surprisingly). These are
left for follow-up changes.

Also, support negative assertions in completion
@rank markers.

Change-Id: I2ae62c2b83a366a37bdd8db88e28cca4c5f92ae5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/569435
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-03-07 20:03:24 +00:00
rogeryk accb00bd1e gopls/internal/server/semantic: highlight the doc links in comments
Code comments contain many references to identifiers, highlighting these
references will make reading easier. Due to consistency and performance
considerations, only doc links are supported this time. Subsequent
changes will support hover and definition.

Updates golang/go#64648

Change-Id: I6b32075d703c03d06aaa16028cf55012d2e52c3c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/553836
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-03-07 19:52:02 +00:00
Alan Donovan ffaa15b2c8 gopls/internal/analysis/stdversion: report refs to too-new std symbols
This CL adds to gopls a new analyzer that reports references to
standard library symbols that are too new for the version of
Go in force in the referring file.

The test is duplicated within the gopls marker framework to
ensure we have coverage of per-file Go versions within gopls.

Updates golang/go#46136

Change-Id: Ic7e04e0ae75a586dc0ac5dfc86c6b4aa67d5d194
Reviewed-on: https://go-review.googlesource.com/c/tools/+/568237
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-07 17:31:08 +00:00
Alan Donovan 9a6aed93ab internal/typeparams: delete OriginMethod
Use Func.Origin instead.

Change-Id: Ie4d29f2bd319a46901ce137107689e37d8e1edfa
Reviewed-on: https://go-review.googlesource.com/c/tools/+/569316
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-03-07 17:26:57 +00:00
Alan Donovan 070fcfb90b internal/typesinternal: delete SetGoVersion
(More obsolete go1.18 compatibility cruft.)

Change-Id: I4da6918058c2dfbe7a18a2bbde245bc81c522314
Reviewed-on: https://go-review.googlesource.com/c/tools/+/569615
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-03-07 17:26:46 +00:00
Rob Findley caf59401b4 gopls/internal/cache: prune broken edges to command-line-arguments pkgs
Fix two bugs discovered during the investigation of golang/go#66109,
which revealed the strange and broken intermediate test variant form
"path/to/command/package [command-line-arguments.test]", referenced from
the equally broken
"command-line-arguments [command-line-arguments.test]". This latter
package was *also* detected as an ITV, which is why we never tried to
type check it in gopls@v0.14.2.

- Snapshot.orphanedFileDiagnostics was not pruning intermediate test
  variants, causing it to be the one place where we were now type
  checking ITVs.
- Fix the latent bug that caused gopls to record a dangling edge between
  the two ITVs.

There is a third bug in go/packages, filed as golang/go#66126.

Fixes golang/go#66109

Change-Id: Ie5795b6d5a4831bf2f73217c8eb22c6ba18e59cd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/569035
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-03-06 17:08:36 +00:00
Alan Donovan ff00c7bd72 internal/stdlib: manifest of all std symbols since go1.0
This CL extracts the std manifest from internal/imports,
and adds minor version and symbol kind information so that
tools such as goimports and the future API version checker
can give version-accurate results.

Updates golang/go#46136

Change-Id: I0785e5f06386f203f811742c477f9ced1c0d72b0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/567837
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-06 14:41:09 +00:00
Jonathan Amsterdam 029c4eaf0e go/analysis/passes/slog: detect unsatifiable interface args
Previously, if we saw an arg of interface type passed to a slog logging
function, we made no assumptions about it.

But we can do better when the argument is in key position:
- If neither string nor slog.Attr can implement the interface,
  we can immediately report an error.
- If only slog.Attr can implement the interface, then we can
  assume that the next position is a key and carry on.

Fixes #65740.

Change-Id: I1080c26b6cb46a46489f811e4cd73c9e505ce6b3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/566895
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-05 19:26:02 +00:00
John Dethridge d10b068e4d go/ssa: handle labeled statements with blank labels
A labeled statement with a blank label can't be the target of a goto,
break, or continue statement, so we don't need to create a new block for
it in builder.stmt.

Function.labelledBlock, which previously would be called to get a new
block, panics for blank labels anyway, because the type-checker doesn't
associate a blank label's *ast.Ident with a *types.Object.

Change-Id: I5f67214c0c35c6c2daf666dc2bd6d0169617e4ee
Reviewed-on: https://go-review.googlesource.com/c/tools/+/568675
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tim King <taking@google.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
2024-03-05 18:10:31 +00:00
cui fliter 4c85bedd11 all: remove redundant words in comments and fix typo
Change-Id: I5f0d0cb5c7fe2f8b12ecf7a141e85ba3831859ce
Reviewed-on: https://go-review.googlesource.com/c/tools/+/569135
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Tim King <taking@google.com>
2024-03-05 15:40:42 +00:00
Peter Weinberger 98c835c38f gopls/protocol: update LSP to latest version
There are no major changes, but new are:
- ClientSignatureInformationOptions.NoActiveParameterSupport
- CodeActionClientCapabilities.DocumentationSupport
- type CodeActionDocumentation referred to in
- CodeActionOptions.Documentation
- Command.Tooltip (which might be useful)
- type LanguageKind string
- type RegularExpressionEngineKind = string
 which is referred to in RegularExpressionClientCapabilities
- new CodeActionKind RefactorMove, and Notebook

The values of InlineCompletionTriggerKind have changed but the names did not.

And, the type TraceValues was renamed TraceValue.

Change-Id: I54d2ecb4a2a55cc24abc71f1f7b292f25bcac8d5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/568475
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-05 15:19:20 +00:00
Gopher Robot 7656c4c657 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I5525544e003e009ee5436c992a14d05b9822b558
Reviewed-on: https://go-review.googlesource.com/c/tools/+/568817
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
2024-03-04 22:41:36 +00:00
Alan Donovan 5bf7d00529 cmd/callgraph: add 'posn' template helper
This change adds a helper function to the template environment
to make it easier to compute the token.Position of an ssa Function.

Also, improve the documentation.

Fixes golang/go#65980

Change-Id: I16d4cc87bb6f96985684da5ce027be296f22a601
Reviewed-on: https://go-review.googlesource.com/c/tools/+/567838
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-29 21:45:52 +00:00
Alan Donovan 283fce21c1 x/tools: drop go1.18 support
Updates golang/go#64407

Change-Id: I247a7ff7f07613674f8e31e4cb9c5a68762d2203
Reviewed-on: https://go-review.googlesource.com/c/tools/+/567418
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-29 16:54:26 +00:00
Tim King 7f348c7a4c internal/versions: updates the meaning of FileVersions.
For Go >=1.22, FileVersions returns an unknown [invalid] Future version
when the file versions would be invalid. This better matches
go/types.

For Go <=1.21, FileVersions returns either the runtime.Version()
or the Future version.

Adds AtLeast and Before for doing comparisons with Future.

Updates golang/go#65612
Fixes golang/go#66007

Change-Id: I93ff1681b0f9117765614a20d82642749597307c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/567635
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-28 22:27:48 +00:00
Alan Donovan 38b0e9bfdb x/tools: add explicit Unalias operations
This change is the result of an audit of all type assertions
and type switches whose operand is a types.Type. (These were
enumerated with an analyzer tool.)

If the operand is already the result of a call to Underlying
or Unalias, there is nothing to do, but in other cases,
explicit Unalias operations were added in order to preserve
the existing behavior when go/types starts creating explicit
Alias types.

This change does not address any desired behavior changes
required for the ideal handling of aliases; they will wait
for a followup. In a number of places I have added comments
matching "TODO.*alias".

It may be prudent to split this change by top-level directory,
both for ease of review, and of later bisection if needed.

During the audit, there appeared to be a recurring need
for the following operators:
- (*types.Func).Signature (golang/go#65772);
- Deref(Type): it's easy to forget to strip off the
  Alias constructor;
- ReceiverName (CL 565075), for destructuring receiver
  types such as T and *T, in which up to two Aliases
  might be present.

Updates golang/go#65294

Change-Id: I5180b9bae1c9191807026b8e0dc6f15ed4953b9a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/565035
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-02-28 21:26:44 +00:00
Alan Donovan a6c03c86fe x/tools: update telemetry import (new Start API)
Change-Id: I78701b620029a94b47524f5d4a77c35a86df2e4e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/564337
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-02-28 20:27:29 +00:00
Alan Donovan 1f7dbdf01a gopls/internal/cache: add debug assertions for bug report
Updates golang/go#65960

Change-Id: I01a416a0cf9cf8e13195c0d9405008ded1a9c53a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/567416
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-28 19:29:29 +00:00
Rob Findley 4d4e802874 gopls/doc: address additional comments on workspace.md
Address follow-up comments on CL 566936.

Change-Id: I03160f4b58dc64fbde32bf4bfc0ce605573641d1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/567255
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
2024-02-28 19:27:47 +00:00
Martin Asquino abe5874e80 gopls/internal/analysis: add fill switch cases code action
This PR adds a code action to fill missing cases on type switches and
switches on named types.

Rules are defined here: https://github.com/golang/go/issues/65411#issuecomment-1922127508.

Edit: I added some tests, but I'm sure there are still things to fix so
sharing to get some feedback.

Fixes https://github.com/golang/go/issues/65411

https://github.com/golang/tools/assets/4250565/1e67c404-e24f-478e-a3df-60a3adfaa9b1

Change-Id: Ie4ef0955d0e7ca130af8980a488b738c812aae4d
GitHub-Last-Rev: a04dc69c7b
GitHub-Pull-Request: golang/tools#476
Reviewed-on: https://go-review.googlesource.com/c/tools/+/561416
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-02-28 16:14:39 +00:00
Rob Findley fc70354354 gopls/internal/test: add test for NPE in control flow highlighting
Add a test for the fix in golang/go#65952: a nil pointer exception when
highlighting a return value in a function returning no results.

Also, merge tests related to control flow highlighting, since it is
convenient to be able to run them together, and since there is
nontrivial overhead to tiny tests.

Updates golang/go#65952

Change-Id: Ibf8c7c6f0f4feed6dc7a283736bc038600a0bf04
Reviewed-on: https://go-review.googlesource.com/c/tools/+/567256
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
2024-02-27 17:43:05 +00:00
sivchari 77c2a67177 benchmark/parse: fix format
The format of the parse_test.go file was not consistent. This commit
fixes the format of the file.

Change-Id: I5ee8d5ae77b9830f58f15d83e724875367e894bd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/566376
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2024-02-27 16:40:19 +00:00