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

1715 Коммитов

Автор SHA1 Сообщение Дата
Viktor Stanchev 515711824d gopls/internal/lsp/source: put testing.T/B first when extracting
Put the testing.T/B second when extracting functions/methods.
It's next after context.Context.

Fixes golang/go#69341

Change-Id: Idcfc0e09e4174646a3f136dcc5badfda4af9938e
GitHub-Last-Rev: 99de9722e6
GitHub-Pull-Request: golang/tools#517
Reviewed-on: https://go-review.googlesource.com/c/tools/+/610976
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Tim King <taking@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Tim King <taking@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-09-11 21:24:47 +00:00
Alan Donovan 288437536f gopls/internal/golang: Definitions: support renaming imports in doc links
This CL adds support for jumping to the definition of a doc link when
the import is renamed. Before, the doc link had to use the local
(renamed) name, which is unnatural; now, it can use either the local
name or the package's declared name.

+ test

Updates golang/go#61677

Change-Id: Ibbe18ab1527800c41900d42781677ad892b55cd4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/612045
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>
Commit-Queue: Alan Donovan <adonovan@google.com>
2024-09-11 20:58:02 +00:00
Rob Findley fd7ab2daaa gopls/internal/server: fix build following semantic merge conflict
Fix the gopls build, which was broken by a semantic merge conflict with
CL 548675 (the slices package was made obsolete after updating to Go
1.23.1).

Change-Id: Ic8b82598b66c560298dd9b8f968a1087e12320f3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/611839
Reviewed-by: Hongxiang Jiang <hxjiang@golang.org>
Reviewed-by: 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-09-10 16:53:39 +00:00
Ethan Reesor dc4c52551c gopls/internal: test discovery
Implements test discovery. Tests are discovered as part of the type
checking process, at the same time as method sets and xrefs, and cached.
Does not implement the Modules command.

Adds static detection of simple subtests. This provides a framework for
static analysis of subtests but intentionally does not support more than
the most trivial case in order to minimize the complexity of this CL.

Fixes golang/go#59445. Updates golang/go#59445, golang/vscode-go#1602,
golang/vscode-go#2445.

Change-Id: Ief497977da09a1e07831e6c5f3b7d28d6874fd9f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/548675
Reviewed-by: Alan Donovan <adonovan@google.com>
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>
2024-09-10 14:00:01 +00:00
Alan Donovan 8ba9169164 gopls/internal/golang: Highlight: work around go/types bug
go/types sometimes fails to annotate type information onto
nested composite literals when there is a type error (#69092).
This CL adds a workaround to one particularly vulnerable place
in gopls that crashes when this happens. (There are potentially
many others.)

+ test

Fixes golang/go#68918

Change-Id: I73e8e1dd8eb8965bde44d8ee3672a50ac362af52
Reviewed-on: https://go-review.googlesource.com/c/tools/+/612042
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-09-09 22:08:14 +00:00
Rob Findley 1dc949f0bf internal/settings: simplify linking now that we only build with 1.23
Since gopls now only builds with the latest version of Go, we no longer
need special linking to align with the compatibility windows of gufumpt
or staticcheck.

Updates golang/go#65917

Change-Id: I7d5ebe6807b34ed8d44e726c7a6585d4c7c7e696
Reviewed-on: https://go-review.googlesource.com/c/tools/+/612055
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-09-09 18:54:26 +00:00
Alan Donovan c2e057bbd2 gopls: use Func.Signature everywhere
Updates golang/go#65917

Change-Id: I20bec8b0a1778f0d2d81f729d12ba966799c7805
Reviewed-on: https://go-review.googlesource.com/c/tools/+/612037
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-09-09 18:09:59 +00:00
Rob Findley 6b0cfffedf internal/test/marker: support multi-line locations
Address a long-standing TODO to permit multi-line locations in the
codeactionedit marker. This should unblock use of codeactionedit with
CL 610976.

Also use a 'converter' wrapper to add a bit more type safety in argument
conversion functions.

Change-Id: I851785c567bcde1a8df82a7921c2fba42def9085
Reviewed-on: https://go-review.googlesource.com/c/tools/+/612035
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-09 18:05:55 +00:00
Alan Donovan 9d7d14e469 x/tools/gopls: delete code obsoleted by go1.23
The util/slices package has been deleted; but util/maps
has been renamed to moremaps since it still has some
useful things.

Note: the standard maps.Clone may return nil.

Updates golang/go#65917

Change-Id: Ide8cbb9aa13d80a35cdab258912a6e18a7db97c6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/611837
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-09-09 18:00:29 +00:00
Rob Findley 4bcf6a3b56 internal/golang: add a fast path for FormatVarType with gopls at 1.23
Now that gopls is only built with Go 1.23, we can rely on
types.TypeString to preserve alias information, and only need the
bespoke logic of FormatVarType to handle the cases where types contain
an invalid type.

This should improve performance for completion, particularly since it
affects the single-threaded construction of candidates.

For example, here is the impact on a relevant benchmark:
Completion/kubernetes_selector/edit=false/unimported=false/budget=100ms

Results:
│ before.txt  │              after.txt              │
│   sec/op    │   sec/op     vs base                │
  81.29m ± 1%   65.83m ± 1%  -19.02% (p=0.000 n=10)

│   before.txt   │               after.txt                │
│ cpu_seconds/op │ cpu_seconds/op  vs base                │
  151.8m ± 15%     101.1m ± 33%  -33.36% (p=0.000 n=10)

Change-Id: I60d890ca102a97cf6b198621ba82afe7eeab7fb9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/611836
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-09-09 15:46:59 +00:00
cuishuang 7398f36f57 all: fix some symbols error in comment
Change-Id: If4bd2e8cd8dded33d434f4b60217fa46fcf5e934
Reviewed-on: https://go-review.googlesource.com/c/tools/+/611796
Reviewed-by: Michael Matloob <matloob@golang.org>
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>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2024-09-09 14:44:08 +00:00
Rob Findley 9f9b7e39b5 gopls/internal/settings: add missing deep cloning in Options.Clone
As noted in a TODO, it appeared that settings.Clone was failing to deep
clone several map or slice fields. A test revealed that ten (!) fields
were not deeply cloned.

Fix this by:
1. Removing pointers and interfaces from settings.Options, by making
   ClientInfo a non-pointer, and by making LinksInHover a proper enum.
2. Adding a deepclone package that implements deep cloning using
   reflection. By avoiding supporting pointers and interfaces, this
   package doesn't need to worry about recursive data structures.

Change-Id: Ic89916f7cad51d8e60ed0a8a095758acd1c09a2d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/606816
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-09-06 21:56:41 +00:00
Rob Findley dc4d64cc1c gopls: fix non-constant format strings
Fix vet failures related to the new vet check for non-constant format
strings with no args (golang/go#60529).

Change-Id: If63006613ec4827b8f7d23990654f5ecc1521ec8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/610795
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-04 18:00:29 +00:00
Rob Findley ce02ccd159 gopls/internal/test/marker: simplify completion markers
Simplify the rank, rankl, and snippet markers, and address TODOS, by
introducing a completionLabel parameter type which may be converted from
a string literal or completionItem (by taking its label).

This change allowed the rank and rankl markers to be combined, and
eliminates the need to use @item markers in snippet tests, just to
extract their label.

This will make it easier for external contributors to add tests for
completion, such as in CL 608695.

Change-Id: I0f848b788ac4cb179a8ce264d99f93c952a0bdd7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609595
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-29 16:17:54 +00:00
xzb 4ead70ccce gopls: report semantic tokens of top-level type constructor modifiers
These new semantic type modifiers will be reported in places of type definition,
type embedding, type alias, variable definition, parameter type,
return type and comments link.

Fixes golang/go#68975

Change-Id: I21ebd758351ee4c6e7bd7a0d34a093b3a6ad4ac8
GitHub-Last-Rev: f825f8aeb7
GitHub-Pull-Request: golang/tools#511
Reviewed-on: https://go-review.googlesource.com/c/tools/+/608156
Reviewed-by: 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>
Auto-Submit: Robert Findley <rfindley@google.com>
2024-08-28 20:45:25 +00:00
Rob Findley 826d8d971b gopls/internal/cache: add a note about GOMEMLIMIT and ballasts
As suggested post-submit in CL 608796, add a note explaining why
GOMEMLIMIT doesn't help gopls solve its GC CPU problems, and a ballast
is still necessary.

Change-Id: Ia452129e259c6f44a0f807028543699d3dd19495
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609236
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-28 17:58:38 +00:00
Rob Findley aaf49f1fb8 gopls/internal/cache: add a 100MB ballast to reduce GC CPU
As described in the doc comment, add a 100MB ballast to reduce GC CPU in
small workspaces or during gopls startup.

Change-Id: I43ff2dcd15e62bebde43fb27567d19e462b2fa22
Reviewed-on: https://go-review.googlesource.com/c/tools/+/608796
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-28 16:26:39 +00:00
Rob Findley 12307aad20 gopls/internal/util/lru: make lru.Cache generic
The lru.Cache type was written before we could use generics in gopls.
Make it generic, to benefit from a bit more ergonomic APIs.

Change-Id: I8475613580156c644b170eaa473f927f8bd37e67
Reviewed-on: https://go-review.googlesource.com/c/tools/+/608795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-08-28 16:22:06 +00:00
Rob Findley 594cdabebb gopls: increment the telemetryprompt acceptance counter for each session
Increment the gopls/telemetryprompt/accepted counter every time we read
the prompt file, so that we can actually use the resulting data. We
don't upload any counter files that overlap with periods of time when
telemetry uploading was not enabled, so with the previous model of only
incrementing the counter at the moment the prompt was accepted, we will
never upload the counter file into which the acceptance is recorded.

With the new model, the counter will give us a sense of what fraction of
telemetry participants opted-in as a result of the prompt.

For golang/go#68770

Change-Id: I8890c73b5bfa19023bb24fd156bcaa9eb46295ad
Reviewed-on: https://go-review.googlesource.com/c/tools/+/607758
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-28 15:34:29 +00:00
Ethan Reesor f5c7449850 gopls/internal: implement Packages command
Implements the `gopls.packages` command.

Updates golang/go#59445

Change-Id: Ia72a971b7aac9baa964c8cf5eee8b332b3125fa4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/600355
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-08-22 18:55:30 +00:00
Ethan Reesor e5e8aa8472 gopls/internal: implement Modules command
Implements the `gopls.modules` command.

Updates golang/go#59445

Change-Id: Ifb39e0ba79be688af81ddc6389570011b4d441cc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/598815
Reviewed-by: Alan Donovan <adonovan@google.com>
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>
2024-08-22 00:06:43 +00:00
Alan Donovan e104dc835a gopls/internal/settings: rename goTest code action to source.test
Change-Id: I0ef0285cd35e32d259a7dc0bb9712ff61d99f3f6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/604795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-08-15 21:04:46 +00:00
Alan Donovan 136c165474 gopls/internal/cache: remove spurious assertions
The various assertions that the package "unsafe" has
Metadata ID "unsafe" all appear to be false when using
Bazel via its gopackagesdriver.

I was (rather embarassingly) unable, within a reasonable
amount of time, to successfully analyze a trivial
hello-world Bazel project using the gopackages debugging
tool and the Bazel gopackagesdriver, so unfortunately
I can't verify the bug or its fix. The documentation
https://github.com/bazelbuild/rules_go/wiki/Editor-and-tool-integration#standard-library
seems to say that all the std packages should be recognized
as command-line targets. Nonetheless, the issue is clearly
related to Bazel from the statistics, and the ID==PkgPath
assumption is clearly unwarranted.

Fixes golang/go#60890

Change-Id: I4769083bfb0cba0a8698c7ec2e8e7b2d044e3a5c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/605735
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-08-15 15:01:08 +00:00
Rob Findley 7cc3be7d11 internal/imports: use a clean GOMODCACHE for the scan root directory
The directories processed by gopathwalk are clean, yet in the scan
callback are assumed to have the root as a prefix. For the module cache,
this root was previous not guaranteed to be clean, if it came from a
GOMODCACHE environment variable. As a result, the computed relative path
may be inaccurate, and may even panic if the unclean root is much longer
than its clean form.

Reproduce the crash of golang/go#67156 in a test, update
scanDirForPackage to be more robust, and fix the uncleanliness of the
module cache root.

Also fix some handling of GOMODCACHE cleanup in imports tests.

Fixes golang/go#67156

Change-Id: Ia899256fed9629b7e753a52feb02b4235bfc8388
Reviewed-on: https://go-review.googlesource.com/c/tools/+/603635
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-08-13 17:53:00 +00:00
Alan Donovan e6bef924df gopls/internal/golang: downgrade assertion in methodsets index
A query for exported method T.M triggers a paradoxical
methodset(T)={} assertion. But an ill-typed T may have
both a field and a method named M causing the methodset
to indeed be empty.

+ Test.

Fixes golang/go#67978

Change-Id: Iecbf98ff53afab00ebb51f83ed261a0318b42771
Reviewed-on: https://go-review.googlesource.com/c/tools/+/605015
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-08-12 22:27:54 +00:00
ZHOU Zehua a76f882cf0 gopls: enhance read/write access distinction in document highlighting for symbols
The definition of 'write access' is same as it in GoLand. Some examples are
access to variables in declaration, assignment(left value), self increasing,
channel sending and composite literal.

The algorithm to find write access is same as it in jdt (Java LSP), by
visiting every write statement in ast traversal and collecting the positions
of access to variables.

Fixes golang/go#64579

Change-Id: I497ec7f15906cf4157ad1965e01264eb35ce973b
GitHub-Last-Rev: cee436c69b
GitHub-Pull-Request: golang/tools#503
Reviewed-on: https://go-review.googlesource.com/c/tools/+/597675
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>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-08-10 20:21:02 +00:00
idnandre 4653e48eb8 gopls/internal/analysis: add skipped analysis simplify on generated code
On generated code, gopls always suggest to simplify code produced literals polluting the "Problems" pane in IDE, while properly refusing to format file on save because it is generated code.

This change will make simplifycompositelit, simplifyrange, simplifyslice skipped on generated code, so it will not polluting the "Problems" pane in IDE.

Fixes golang/go#67733

Change-Id: I99b3f083ce96594f360576f530cfc7f4b77c1cc1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/598835
Reviewed-by: 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-08-06 13:34:56 +00:00
Alan Donovan f855a53930 gopls/internal/telemetry/cmd/stacks: use authentication token
GitHub imposes a stringent rate limit for unauthenticated requests,
that our current rate of telemetry often exceeds.
This change causes the stacks command to read a GitHub
authentication token from $HOME/.stacks.token and use it if found,
relaxing the rate limit. Instructions for creating a token are
recorded in comments.

Fixes golang/go#68733

Change-Id: Ia4b73faa1340dfbed4b9b350d2c57f09abf8ca38
Reviewed-on: https://go-review.googlesource.com/c/tools/+/603155
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-08-05 18:50:33 +00:00
Alan Donovan f6a239054f gopls/doc: delete commands.md
This change deletes the public documentation of gopls'
command set, which is an internal implementation detail.
Adventurous users can read the source of command.Interface.

Also, delete the Commands portion of the JSON API,
which is not used.

Change-Id: Ib2e2e8fcee880805c6556ee40fcbe1891712af5a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/597276
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-01 00:23:54 +00:00
Alan Donovan 2154cbf88d gopls/internal/golang: add "Browse gopls features" code action
This command opens the Index of Features doc page:

  $ gopls codeaction -kind=gopls.doc.features -exec ./gopls/main.go

VS Code exposes this new code action through the Quick Fix
menu (Command-.) under the section "More actions...".
It should probably also be given a top-level command similar
to "Go: Add Import", etc.

Other editors seem to treat code actions
more uniformly, so special handling is unnecessary.

Change-Id: I633dd34cdb9005009a098bcd7bb50d0db06044c7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/595557
Commit-Queue: 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>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-08-01 00:23:45 +00:00
Alan Donovan 444aadd6e6 gopls/internal/cmd: redesign codeaction subcommand
This CL redesigns the codeaction subcommand (formerly named "fix")
to make it more regular and useful:
- By default, filtered (matching) code actions are merely printed
  unless the -exec flag is specified, as with 'gopls codelens'.
  In particular, this means that the tests no longer have the
  side effect of executing any action that is always offered,
  such as the forthcoming "open gopls documentation" action.
- By default, all kinds of actions are returned unless explicitly
  filtered with a -kind flag.
- The -all flag, which prevented discarding of non-preferred
  actions, has gone away. (All gopls actions are non-preferred,
  at least for now, so no flag is needed; if things change,
  the flag should be a tristate -preferred=auto|true|bool.)
- The "fix" command is retained as a trivial stub for clarity.
- Actions may be filtered by -title=regexp.
- Disabled actions are discarded.

Change-Id: Ic88c1232bbc7ff24ae33e6427c3773cb2564eb06
Reviewed-on: https://go-review.googlesource.com/c/tools/+/596797
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-07-26 20:00:48 +00:00
Hana (Hyang-Ah) Kim ef4d0833eb gopls/internal/protocol/command: draft Packages/Modules API
This new Packages command provides information about
go packages known to gopls. The Modules command reports
modules known to gopls and found in the directory.

For golang/go#59445

Change-Id: Ief0ac4984efb4a0e7f0fee8d8d55dae35eb00375
Reviewed-on: https://go-review.googlesource.com/c/tools/+/579438
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Ethan Reesor <ethan.reesor@gmail.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-07-11 15:04:06 +00:00
Muir Manders d29feb5f4a gopls/completion: prefer rangeable funcs in range statements
Teach gopls that `range` statements can accept iterator funcs per
upcoming Go 1.23 language change (and Go 1.22 "rangefunc" experiment).

I didn't bother disabling this preference for earlier versions of Go
since false positive completions seem unlikely.

For golang/go#66637

Change-Id: Id57687f3fa205fa8e4b4616eebee471e6d11d802
Reviewed-on: https://go-review.googlesource.com/c/tools/+/592915
Reviewed-by: 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>
Run-TryBot: Muir Manders <muir@mnd.rs>
Auto-Submit: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-07-10 19:37:53 +00:00
Alan Donovan 71c553722e gopls/internal/analysis/fillswitch: use qualified type names
The message is now of the form "Add cases for pkg.Type" when
the type is imported from another package.

Fixes golang/go#68225

Change-Id: I310f5354d2fb519c1e85d37b313594ccd50353f0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/597275
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-07-09 13:40:23 +00:00
Hongxiang Jiang 0e7ccc0478 gopls/internal/golang: provide version info for stdlib in pkgdoc
The available versions are provided for functions and methods.
Same as https://pkg.go.dev/

1. The std lib version is only available for FUNC, METHOD, TYPE. Not
   available for CONST, VAR & FIELD. Because those types do not have
   dedicated HTML element, declarations are shown only as source code.
2. Introduce css element stdlibVersion which contains the styles needed.

For golang/go#67159

Change-Id: I4b4f469a858a1aca6598f2abed6f990ab1931b00
Reviewed-on: https://go-review.googlesource.com/c/tools/+/595855
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-07-02 16:56:45 +00:00
Rob Findley fcf5463260 gopls/internal/server: add counters to inform v0.17.0
Add two counters to help inform decisions for gopls@v0.17.0:

- Add a gopls/gotoolchain:{auto,local,other} counter to help us
  understand toolchain upgradability.
- Add a gopls/telemetryprompt/accepted counter to track telemetry prompt
  acceptance.

Fixes golang/go#68240

Change-Id: I8fc06b3a266761dbf7c2781267dfb1235eef1a63
Reviewed-on: https://go-review.googlesource.com/c/tools/+/595560
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2024-06-28 20:28:24 +00:00
Alan Donovan 799a47185d gopls/doc: document all of gopls' features
This CL enumerates and documents each LSP feature
supported by gopls so that users can find out:
- what the tool is capable of,
- how to use it,
- what settings affect the feature, and
- whether their LSP client supports a given feature.

We plan to provide Code Actions to open the relevant
section of the manual, e.g. "Refactor > Describe refactorings..."

To review the markdown, cherrypick this CL then
run this command from x/tools:

 $ go run rsc.io/cmd/mdweb@latest -a localhost:9876 &
   open http://localhost:9876/gopls/doc/features/README.md

The topic of completion is left for another day,
as is support for go.mod files.

Updates golang/go#54115

Change-Id: I8f7de7571bfe0355b3597487efbc0d7aae7a12d6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/583316
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-06-28 16:11:53 +00:00
Hongxiang Jiang 2e239ad1ba gopls/internal/golang: provide version info for stdlib fields
For golang/go#67159

Change-Id: I8b8b12949566857f29460675b9dc4d9c6804ff1e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/595336
Auto-Submit: Hongxiang Jiang <hxjiang@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-27 20:41:40 +00:00
Alan Donovan bc15dd8597 gopls/internal/analysis/fillstruct: use package name (not path) in UI
Also, factor out three instances of the type qualifier as
typesinternal.NameRelativeTo.

Change-Id: I22c1e8f89e77a7164c178cf335253a097b9850be
Reviewed-on: https://go-review.googlesource.com/c/tools/+/595119
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-06-27 18:36:39 +00:00
Rob Findley 72edac2ff3 internal/typeparams: fix crash in interface hover with empty type set
The logic of typeparams.Free.Has was not handling ErrEmptyTypeSet from
InterfaceTermSet, leading to a crash.

Also fix a hover marker in hover/generics.txt that was apparently
missing a '@'.

Fixes golang/go#68213

Change-Id: I0e264b5c5f5ecc0d09a0b8ab381eb7d7c492c18f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/595555
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-06-27 18:14:51 +00:00
Alan Donovan c0ae6bbd24 gopls/internal/golang: splitlines: s/parameter/arguments/ in CallExpr
(Another terminological nitpick that I missed until reading the docs.)

Also, commentary.

Change-Id: I8d985234637224be7b921bdaa8113baa9c54be66
Reviewed-on: https://go-review.googlesource.com/c/tools/+/595118
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-06-27 18:11:25 +00:00
Alan Donovan 5cc2d0b12c gopls/internal/golang: splitlines: remove workaround for golang/go#68202
There's no need for splitlines to handle FuncDecl since it
handles FuncType... now that the bug in PathEnclosingInterval
is fixed.

Updates golang/go#68202

Change-Id: I3c96535b87c62e5d2a5b68ec66fed7df50b5d6c4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/595196
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-06-27 17:53:20 +00:00
Alan Donovan 69160777a9 gopls/internal/golang: don't panic when findKeyword fails
As the existing comment attests, this can happen in the wild.
Just skip it and move on.

+ a test

Fixes golang/go#68205

Change-Id: I3227b0ce7ffacf3c8b4bbf2180a10e218bf87aa3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/595117
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-06-27 17:52:59 +00:00
Hana (Hyang-Ah) Kim 8fa4173de3 gopls/internal/server: conditionally prompt for telemetry
Previously, VS Code Go extension conditionally asked gopls to
consider to prompt, only if
  * it thinks telemetry data was logged for 7days+, and
  * the user is selected (based on hash of vscode cliet id)

This change implements the condition checking inside gopls,
so we can enable prompting for other editor users and simplify
vscode-go's code.

The prompt file format is changed.
   old format: <state> <prompt_count>
   new format: <state> <prompt_count> <creation_unix_time> <token>

where
 - creation_unix_time is the guessed telemetry start time (unix time)
 - token is a random integer in [1, 1000], which is used in sampling
  decision.

This CL adds environment variables to control the creation_unix_time
and token values in integration testing. They are also useful for
manual testing, and for VS Code Go prompt logic migration.
VS Code Go extension had been used a vscode machine id hash
and kept its observed telemetry start time in memento. The env vars
can be used to forward the info to gopls.

For golang/go#67821

Change-Id: I13d2bf6d43ea1e5ef8ebec7eb2f89fc9af8a8db7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/589517
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-27 14:23:27 +00:00
Hongxiang Jiang b9a361aa9c gopls/internal/golang: provide version info for stdlib methods
For golang/go#67159

Change-Id: If3d09a39e8bf0a5ab61dc0953d7250ad75525372
Reviewed-on: https://go-review.googlesource.com/c/tools/+/595135
Reviewed-by: 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-06-27 02:53:05 +00:00
Hongxiang Jiang 3db1ddbb31 gopls/internal/golang: provide available version info in stdlib hover
Version is only available for the types of Var, Func, Const & Type.

For golang/go#67159

Change-Id: I77f95ccb6027914440ec7a2ea5338318c0f88e60
Reviewed-on: https://go-review.googlesource.com/c/tools/+/594875
Reviewed-by: 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-06-26 18:10:18 +00:00
Rob Findley 008ed2c691 gopls/internal/golang/completion: fix package clause completion suffix
CL 585275 introduced a call to completion.Surrounding.Suffix that
exposed a latent bug in package clause completions: the completion
content was not being correctly computed as containing the cursor.

Fix the heuristics for completing at "package<whitespace>|", so that the
surrounding content is correct.

As a result of this change the 'editRegexp' from some completion tests
now no longer includes the newline, which also seems more correct.

Fixes golang/go#68169

Change-Id: I32ea20a7f9f0096aef85ed77c64d3b4dfeedef45
Reviewed-on: https://go-review.googlesource.com/c/tools/+/594796
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Auto-Submit: Robert Findley <rfindley@google.com>
2024-06-26 17:42:31 +00:00
Alan Donovan b297f5a4df gopls/internal/golang: s/return values/results/
(A terminological nitpick.)

Change-Id: I4ecd8141c547d0f385623159e32f9ce58e3e672a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/595155
Auto-Submit: Alan Donovan <adonovan@google.com>
Commit-Queue: 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-06-26 17:06:19 +00:00
Rob Findley b5bfa9cc3f gopls/internal/fuzzy: move the fuzzy package to gopls
While reviewing CL 592519, I had to pause to confirm that the fuzzy
matcher is only used by gopls, and so we are therefore free to change
its matching heuristics.

Move the library to the gopls module to make this relationship more
apparent.

Change-Id: I2d097fe68cfb6c83d82a09c63eddd8b7462f6ec7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/595115
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-06-26 14:45:46 +00:00
Rob Findley 02912f74a5 gopls/internal/cache: lift package caching to forEachPackage
For some reason this solution didn't occur to me in CL 512636. By
lifting this handling out of forEachPackageInternal, we simplify the
logic of type checking.

Change-Id: Ie8738d04aa5e1e4811f978f2ebe2d1cfc3b839b0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/591918
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-06-26 14:39:32 +00:00