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

2115 Коммитов

Автор SHA1 Сообщение Дата
Alan Donovan 752860b84e gopls/internal/protocol/command: simplify ApplyFix
- combine URI + Range into one Location field
- factor n calls addCommand(NewApplyFixCommand).

Change-Id: I01c4ff7efeaa577331253348f4816a3a82b80db0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/614157
Commit-Queue: Alan Donovan <adonovan@google.com>
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-23 18:23:46 +00:00
Alan Donovan fadcea546d gopls/internal/golang: CodeAction: split into producers
This CL splits the ad hoc CodeAction function and its
many callees into a uniform list of "producer" functions,
each responsible for a single CodeActionKind.

Each producer is called only if its kind is enabled
by the request, and any actions created by the producer
automatically have the appropriate kind.

Only producers that request type information will get it.

To avoid redundant computation when two producers need
the same information, the lazyInit mechanism allows
them to share common results, similar to sync.Once.
For example, quickFix and sourceOrganizeImports share
the results of a call to allImportsFixes.

Change-Id: I4034970ed9b1e872d5c9bf4b085b98a121fa7144
Reviewed-on: https://go-review.googlesource.com/c/tools/+/612495
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-09-23 18:23:05 +00:00
Alan Donovan 1d5e334177 internal/aliases: remove Alias and Unalias
These two declarations can now safely be accessed directly
from go/types.

Also, remove all mention of internal/aliases from gopls/...
We can enable two suppressed tests now that go1.23 is assured.

Updates golang/go#46477

Change-Id: I9ae8536b0d022e3300b285547c18202bed302cf2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/614638
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Tim King <taking@google.com>
Reviewed-by: Tim King <taking@google.com>
2024-09-20 19:51:09 +00:00
Alan Donovan d09d36b49f x/tools: remove refs to cmd/gorename
Too bad I didn't include refactor/{rename,importgraph}
in the current proposal; they will need another.

Updates golang/go#69360

Change-Id: I8af544515893a0663621a19768adf64798c93671
Reviewed-on: https://go-review.googlesource.com/c/tools/+/614159
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-19 23:09:23 +00:00
Alan Donovan 45851d3dc0 gopls/internal/telemetry/cmd/stacks: show build failure stderr
And other minor tweaks.

Change-Id: Ic16024cb2630d4ba144ead38856595ea8f6d81dd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/614178
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-19 15:56:50 +00:00
Hana (Hyang-Ah) Kim c8d229cde8 all: fix spelling errors
Reported originally in CL 611915 (vscode-go PR 3529).

And ran golangci-lint misspell checker to find a couple more.

Change-Id: I2dac2901191cc8759f0bd6b2084b61dbba174dd6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/614156
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-09-18 20:18:32 +00:00
Alan Donovan bea7373d8a gopls/internal/protocol/command: remove nuisance error handling
The various command.NewXXXCommand functions all used to return
an error in case argument marshalling failed. However, in 100%
of cases, the particular argument types have infallible JSON
marshalling. This change emits the error handling code only
in the fallible cases (none yet).

Also, the New functions now return a pointer to a Command,
(as they should), simplifying surrounding logic.

(This is a preparatory cleanup for CL 612495.)

Change-Id: I2dac9f84034c2fade2ca05adc62129afc78e1cfe
Reviewed-on: https://go-review.googlesource.com/c/tools/+/613263
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-09-18 14:43:40 +00:00
Alan Donovan e603756b2b gopls/internal/cache: add telemetry counter for GOPACKAGESDRIVER
Update a counter each time we observe a gopackages driver in
use. This will help us understand the conditions that led to
some crashes reported by telemetry.

Updates golang/go#60890

Change-Id: Ieca522c22b6f5bc9756210627bba82934946eaf8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/594955
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-17 18:54:47 +00:00
Rob Findley 42b921c744 gopls/internal/test/integration: skip BenchmarkPackages with -short
The new BenchmarkPackages test is failing on the perf builder, because
the gopls.packages command is not supported by gopls@v0.11.0. By
convention, skip this benchmark with -short to filter it out from the
set of benchmarks run by x/benchmarks.

Change-Id: I5e6cc22212644be0a4fc2e6d8f4ce0f282330e00
Reviewed-on: https://go-review.googlesource.com/c/tools/+/613718
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-17 18:32:22 +00:00
Rob Findley a58d83bcd9 gopls/internal/cache: build the import map lazily during type checking
For larger repositories, a significant amount of time in the importer is
spent building the import map.

While we don't really want to persist these import maps, which can be
quite large, we can largely eliminate their cost by doing an incremental
breadth-first search of dependencies for the desired import path: most
imports are direct or found within a shallow search starting from the
original package.

As one reference point, the DiagnoseChange/kubernetes benchmark went
from 10% of CPU spent in importMap, to ~0% in importLookup.

Change-Id: I219aa6b7d41dfb11ec5d8a5e3819adc46dd37f2d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/613715
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-09-17 17:12:07 +00:00
Alan Donovan a319a85de8 gopls/internal/telemetry/cmd/stacks: display closed issues white
The isTerminal implementation works for our dev machines,
{darwin,linux} x {amd64,arm}, and avoids a dependency
on x/term, which gopls so far doesn't need... though I
am now tempted to find a pretext for the dependency.

Change-Id: If96b5cf737c9ea998d0612dec294295a5528b22a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/613575
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-16 22:13:00 +00:00
Alan Donovan 5aac53c5ff gopls/internal/golang: Definition: jump to assembly
This CL adds support for jumping to the definition of a function
implemented in assembly. The first Definition query jumps to the
Go declaration, as usual; this func has no body. Executing a
second Definition query jumps to the assembly implementation,
if found.

+ Test, doc, relnote

Fixes golang/go#60531

Change-Id: I943a05d4a2a5b6a398450131831f49cc7c0754e4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/612537
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-16 20:58:43 +00:00
Alan Donovan 8fcd92f832 gopls/internal/telemetry/cmd/stacks: predicate de-duplication
This CL introduces an expression language for matching
stacks, inspired by watchflakes.  Each issue has a block
at the start of its body of this form:

    ```
    #!stacks
    "bug.Reportf" && "golang.Hover:+19"
    ```

where the expression is a sentence of this grammar:

   expr = "string literal"
        | ( expr )
        | expr && expr
        | expr || expr
        | ! expr

A string literal implies a substring match against
a stack trace; the other forms are boolean operations.
The stacks command reads all such predicates at start,
and uses them to associate new stacks with existing
issues. (It reports an error if a stack is claimed by
two issues.) For each claim, it updates the issue
by adding a comment describing all the new stacks
(example: https://github.com/golang/go/issues/60890#issuecomment-2350023305)
and it adds/updates the "Dups: " list on the last
line of the issue body (first comment).

This should greatly reduce the amount of toil in
associating stacks with issues, since we can just
tweak the predicates to accommodate minor variations.

The GitHub auth token now needs R/W access to golang/go issues.

Fixes golang/go#65963

Change-Id: I836cd89bba456826839a389271ac38745e493a54
Reviewed-on: https://go-review.googlesource.com/c/tools/+/613215
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-16 15:23:58 +00:00
Alan Donovan 7891473c01 gopls/internal/telemetry/cmd/stacks: fix two bugs
1. There were three early returns in the frame -> URL
   computation, though it was hard to see, and their
   formatting logic differed. This CL factors them,
   extracting the frameURL function.

2. When git clone fails (e.g. due to no SSO cert),
   we failed to clean up the empty dir, causing a
   persistently stuck failure state. Now we attempt
   to clean up the directory. (This won't help when
   the program is terminated from without.)

Change-Id: I0f7e2dd26b95899ec85b3e4666def374dc8caadd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/613076
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-09-16 14:01:49 +00:00
Kir Kolyshkin 91d4bdb347 gopls: rm GofumptFormat from internal/settings
Since CL 612055 var GofumptFormat can never be nil, and since CL 609655
it is a very simple wrapper.

Remove it, and use mvdan.cc/gofumpt/format directly in internal/golang.

Note that this removes some documentation bits about gofumpt options, but
those are already described in internal/golang.Format inline comments.

Change-Id: Ic7d5b8412e913f2dbbc14befb978f8a4f743334a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/611844
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-09-13 18:33:14 +00:00
Alan Donovan 3e49191340 gopls/internal/telemetry/cmd/stacks: generate CodeSearch links
This CL causes the stacks command to mark up each stack as a
set of links to CodeSearch. In order to do that, it needs to
build the gopls executable at the correct version of gopls and Go
and for the right GOOS and GOARCH, read the pclntab out of the
executable (which is the only authority on how to decode the
symbol names that appear in the stack counter), and then
construct CodeSearch URLs from (version, file, line) triples.

The expensive steps are cached in /tmp/gopls-stacks so that they
are paid infrequently in a typical stacks run.

See https://github.com/golang/go/issues/67288 for an example
of the updated output.

Fixes golang/go#64654

Change-Id: If1c3e42af5550114515b47a22dfa036e8da27143
Reviewed-on: https://go-review.googlesource.com/c/tools/+/611840
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-12 19:13:25 +00:00
Alan Donovan beed481fb5 gopls/internal/settings: use CodeActionKind hierarchy
This change causes all CodeActions returned by gopls to use a
specific leaf type such as refactor.inline.call, instead of a
general category such as refactor or refactor.inline. The
categories may continue to be specified in the "Only" parameter
of a CodeActions request, and they apply hierarchically.
This allows clients to be more specific in requesting a
particular Code Action.

Details of golang/codeaction.go (messy diff):
- don't separate "typed" from "syntax only" operations;
  in practice we always need types.
- enabled (func) replaces want (map). It is computed
  in server.CodeAction and plumbed down.
- the "add" helper wraps a Command in a CodeAction
  and adds it to the result.

Also:
- use camelCase names, following LSP's source.organizeImports.
- document the specific kinds in the user manual
  and add a release note.
- remove the CodeAction title regexp parameter from
  @codeaction{,err} marker tests since the kind is
  now sufficiently expressive.

Fixes golang/go#40438
Updates golang/go#68791
Updates golang/go#68783

Change-Id: I1898f79d8af441a0376ad5067d05e0621840d987
Reviewed-on: https://go-review.googlesource.com/c/tools/+/604818
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-12 17:34:21 +00:00
xizi 15b8886a84 SignatureHelp: report signature of Ident if no enclosing CallExpr
Currently, SignatureHelp reports information only about an
enclosing call expression. But it would be useful to show
signature information after entering the name of a function
such as "f" or "fmt.Println", without call parens.

So, if there is no enclosing call, this change reports the
signature of the selected identifier if it is callable.

Fixes golang/go#68922

Change-Id: Ibb0700e354c5d6e5937fc7f7b5db65e9d96574bb
GitHub-Last-Rev: 5e7965edd3
GitHub-Pull-Request: golang/tools#510
Reviewed-on: https://go-review.googlesource.com/c/tools/+/605983
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-12 14:40:24 +00:00
Kir Kolyshkin 4e8d5c8a99 gopls: bump gofumpt to 0.7.0
Release notes: https://github.com/mvdan/gofumpt/releases/tag/v0.7.0

Note gofumpt now uses go/version to parse version string, so
fixLangVersion is no longer needed, but "go" prefix is a must.

Change-Id: I8b8e0eb3f0268cddf31ef2fcee90566a17a065ee
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609655
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: Alan Donovan <adonovan@google.com>
2024-09-12 14:25:03 +00:00
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 ce7eed4960 doc/generate: minor cleanup
Remove the unused 'upperFirst' function, and fix a potential NPE due to
an incorrect predicate.

Change-Id: I671a3418b82ea77e5c9bb598f2be0b958078e464
Reviewed-on: https://go-review.googlesource.com/c/tools/+/611575
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-09-06 21:37:56 +00:00
Rob Findley 0a498831d1 gopls/go.mod: update the go directive to 1.23.1
With Go 1.23.1 released, fixing some bugs in go/types Alias support, we
can now update the gopls go.mod go directive.

Fixes golang/go#65917

Change-Id: I2d6d3966de424048dceab1b2f7b795ec6998c863
Reviewed-on: https://go-review.googlesource.com/c/tools/+/610936
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-09-05 19:37:13 +00:00
Gopher Robot ad366a81ee go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I7da2478d54e3963cf485b5d95e3b65f03a80343d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/610661
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2024-09-05 17:57:31 +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 70f5626413 all: with 1.23 out, update Go directive to Go 1.22
Now that 1.23 is out, and 1.19 and 1.20 trybots have been updated to be
optional in CL 610395, we can update the go.mod files to use Go 1.22.6.
This will unblock tagging x-repos, since there won't be conflicts with
x/mod.

A subsequent CL will update the gopls go.mod file to 1.23.1, once that
minor version is released (shortly).

For golang/go#65917

Change-Id: I663918f7be5a3e340703ae82e13b93e9e0f2877d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/610435
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-04 14:33:11 +00:00
Rob Findley 063360f92f gopls: update x/telemetry dependency
Update x/telemetry to pick up the fixes for golang/go#68976 and
golang/go#68946.

Commands run (from the gopls module):
  go get golang.org/x/telemetry@f29ab53
  go mod tidy -compat=1.19

For golang/go#68916

Change-Id: Ifbe16ece970a89336f3e372ddfde088cf0770eac
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609195
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2024-08-30 17:49:51 +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