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

2115 Коммитов

Автор SHA1 Сообщение Дата
Gopher Robot 3057be8f63 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I81218876c6b66a0aa17beb6e0917d60cd6987100
Reviewed-on: https://go-review.googlesource.com/c/tools/+/603419
Auto-Submit: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: David Chase <drchase@google.com>
2024-08-06 19:12:18 +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 3ffd605b1e gopls/doc/features: fix prominent typo
Change-Id: I083263af30c4496349864979aec32631cf6474bd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/603115
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-08-05 18:02:16 +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
Alan Donovan ec1a81bfec gopls/doc/features: more doc tweaks
Change-Id: Ia4f473b9ef7fe10463e7bb768801a63aac84e89a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/596796
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-07-22 16:16:40 +00:00
Rob Findley 6f4e2a811e gopls: update x/telemetry dependency
Update x/telemetry to pick up recent bug fixes (notably
golang/go#68311).

Change-Id: Ic95d54fc43872ab5c3548cf47134fbaea27e1487
Reviewed-on: https://go-review.googlesource.com/c/tools/+/598115
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-07-12 22:14:44 +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
Richard Miller febceba19e copyright: don't skip directories "." or ".." in checkCopyright
The checkCopyright function skips directories with names beginning
with "." (for example ".git"). But TestToolsCopyright invokes
the function on directory "..", which means the test is not checking
anything. To avoid this, make an exception to the "." prefix test
so that "." and ".." will still be checked.

Also add a copyright notice to file gopls/doc/assets/assets.go, so
the TestToolsCopyright test will pass when it's no longer skipping
everything.

Fixes golang/go#68306

Change-Id: I773dd29113b34f79ce33a02cb91a53664d26b3df
Reviewed-on: https://go-review.googlesource.com/c/tools/+/596736
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-07-08 17:34:28 +00:00
Gopher Robot 33be3ef892 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: Ia362a291d4c1bad04462b136af09f630c1b5bb05
Reviewed-on: https://go-review.googlesource.com/c/tools/+/596897
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
2024-07-07 19:31:37 +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 70a59b2f22 gopls/doc: respond to Hana's review of CL 583316
Also:
- contributor notes on keeping docs up to date;
- add "Added in v0.17" on "Extract to new file".
- various other fixes and tweaks.

Change-Id: I23666654a55190e99109b11cc65ca175a77de65e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/595835
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-28 18:56:54 +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
Muir Manders 480a22df04 gopls/completion: don't take address of interfaces for "%p" values
When completing printf calls, we previously only preferred
pointers and slices. This meant to make an interface object acceptable
for "%p", we would take its address to turn it into a pointer.

Change "%p" to also prefer interface types in addition to chan, map, and
func, which all have pointer semantics. Note that interface types
don't necessarily contain pointers, but they might, so tacking on "&"
automatically is annoying.

Fixes golang/go#65609

Change-Id: Idf2ba9cf27fa4ea8e721396cded5a7743d79807b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/593575
Reviewed-by: Robert Findley <rfindley@google.com>
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-06-26 14:07:16 +00:00
Chiawen Chen 315127076e gopls/internal: add code action "extract declarations to new file"
This code action moves selected code sections to a newly created file within the same package. The created filename is chosen as the first {function, type, const, var} name encountered. In addition, import declarations are added or removed as needed.

Fixes golang/go#65707

Change-Id: I3fd45afd3569e4e0cee17798a48bde6916eb57b8
GitHub-Last-Rev: e551a8a24f
GitHub-Pull-Request: golang/tools#479
Reviewed-on: https://go-review.googlesource.com/c/tools/+/565895
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>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-06-26 14:07:01 +00:00
Rob Findley 850c7c3070 gopls: skip failing tests on wasm/wasip1
Add skips as appropriate to TestFreeRefs and TestDriverConformance.

Also add a skip for a preexisting failure on wasip1: golang/go#64725.

Fixes golang/go#68163
Updates golang/go#64725

Change-Id: I2827160bad6627755f213e4b8b54d53333d2d98d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/594895
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-06-25 18:01:28 +00:00
Rob Findley dc341221fd gopls/internal/golang: fix hovering from the builtin file
The builtin file represents a psuedo package for builtin documentation.
When hovering over a builtin declared in the builtin file, its
corresponding hover content should be the same as hovering at the call
site.

Fix this by intercepting hover requests originating from the builtin
file. Along the way, fix a bug that jumping to a definition in the
builtin file went to the declaring node, not declaring identifier.

For golang/go#68026

Change-Id: I070ec701cb7e067dd1cbb14a968c063169bb541c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/594795
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-25 17:24:37 +00:00
Alan Donovan 1028e3027a gopls/internal/settings: remove fieldalignment analyzer
Since it doesn't find likely mistakes, it is a poor fit for the
gopls analyzer suite: even when off-by-default, its diagnostics
can be confusing.

Instead, its docs now advise users who come across it to run
it using a standalone singlechecker as desired.

+ release note

Also, we issue a deprecated warning if the user's configuration
enables the deleted analyzer, with a reference to the 0.17
release so that users can find the release note.

Fixes golang/go#67762

Change-Id: I7e2eafc3216df84eb62de132ac2f04e0bf444f92
Reviewed-on: https://go-review.googlesource.com/c/tools/+/590375
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-25 17:18:35 +00:00
Alan Donovan 1e6c1e2be2 gopls/internal/golang: strip @v1.2.3 suffix from pkgdoc URLs
The  package path in a /pkg URL does not want a module
version suffix: the view specifies the versions of all packages.
Remove them.

Fixes golang/go#68116

Change-Id: Icbe7a6e7346d12456724d005fe8f755872657055
Reviewed-on: https://go-review.googlesource.com/c/tools/+/594556
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-06-24 19:46:22 +00:00
Alan Donovan 7de8d0a169 gopls/internal/analysis/simplifyrange: reenable on range-over-func
This reverts the functional change of commit 3629652 (CL 588056) that caused
range-over-func to differ from other range operands; but we keep some tests
and tidy up the logic.

It was decided at the 11th hour to permit redundant blanks in range-over-func
statements in the go1.23 spec; see
https://github.com/golang/go/issues/65236#issuecomment-2187122281.

Fixes golang/go#67239
Updates golang/go#65236

Change-Id: Ib3c1c535a1107a05f18732e07d7c8844bbac4d1e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/594555
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-24 19:31:57 +00:00
Alan Donovan f06ed92a26 gopls/internal/settings: define InlayHints enum
This allows us to simplify both the declaration of the enum
(particularly its doc comments) and the generator logic,
which no longer treats it as a special case.

Now that "analyses" is the only remaining special case
of map[string]bool, consolidate the two generator
hacks for it.

Change-Id: I49d4e3ca41e96d02d8444925cc013e2b19cf2305
Reviewed-on: https://go-review.googlesource.com/c/tools/+/593616
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-24 14:56:03 +00:00
Alan Donovan 833def65e8 gopls/internal/settings: move CodeActionKind values from protocol
Like CodeLensSource, these enum values are gopls extensions (and
their configuration interface) and not part of LSP.

No change to generated files.

Change-Id: I2413fd23acc92450f1f0712f0f77a1c83674505a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/593816
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-24 14:55:40 +00:00
Ethan Reesor 47bd819ea9 gopls/internal/server: fix CSS typo
Change-Id: I391dbba608b24220f4af37f620e5f33acbad1578
Reviewed-on: https://go-review.googlesource.com/c/tools/+/593637
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
2024-06-24 03:50:26 +00:00
Alan Donovan df4e86209a gopls/internal/settings: minor cleanups
This change causes the "env" setting to require
that its JSON value is a mapping from strings to
strings, or int for legacy compatibility; but other
values (float, array, object, null, bool) are now
rejected.

Also, group all the deprecated settings together with
a comment to resist the temptation to delete them.

Change-Id: I7eb2f017e9cda4a3821370034b8e95809a3d8e11
Reviewed-on: https://go-review.googlesource.com/c/tools/+/593075
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-06-21 20:57:32 +00:00
Alan Donovan 2d104ec5d2 gopls/doc/generate: treat LinksInHover as an enum
This CL defines a type for the true|false|"gopls" type used
by linksInHover, and adds a special case to the doc+api generator
to treat it as an enum, so that VS Code will present a better
value-chooser UI for it.

Also, document the type grammar used in the docs.

Updates golang/go#68057

Change-Id: I9e334fbc94dcbdc70657d8e64f67fb807e69cbf8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/593656
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-06-20 18:03:41 +00:00
Alan Donovan b994346592 gopls/doc/assets: create dummy submodule for image files
Contra the previous CL, we decided to store the PNG images
in git, but in a separate submodule so that we don't bloat
the gopls module download.

(These images will also be shared with forthcoming gopls
docs in CL 583316.)

Change-Id: I5bab6114ce10304725ba2ac58a8654c247171801
Reviewed-on: https://go-review.googlesource.com/c/tools/+/593675
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-20 15:34:10 +00:00
Alan Donovan 18e694b54c gopls/doc/release: finalize v0.16.0 release notes
The images are intentionally missing; we don't want to
bloat the repo with PNG files, so I plan to set up
a process for storing images in a blob store later
today, at which point I will update the URLs to point
there. But we can proceed with the release before that.

(Many of these images will be shared with the gopls durable
documentation slowly coming together in CL 583316.)

Change-Id: I508b13ad2ae3b77f08dfeb895472db09542661b2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/593476
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-20 14:44:49 +00:00
Alan Donovan 99779e9a0c gopls/internal/settings: move CodeLensSource from protocol
This enum is properly a setting, not a protocol feature.

The .md and api.json generator script assumes that all enums
are in the settings package, and consequently emitted incorrect
names for this type.

Generator changes in detail:
- remove the package.Load of both "settings" and "protocol",
  reverting part of an early change.
- remove loadAPI special case for "codelenses" not being an
  enum-keyed map, as it is one. (As a consequence, the enum
  values appear in api.json in alphabetical, not declaration,
  order. Also, the title portion of the codelend doc string
  is no longer discarded.)
- add lots of missing commentary.

This may seem like a large change at the 11th hour, but note:
- the only change to the production code is a renaming;
- the effects of the generator changes are entirely confined
  to settings.md and api.json.

Fixes golang/go#68057

Change-Id: I097f0a9b2e34b8f9a3438112b55efb2081b4acb2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/593615
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-20 14:20:31 +00:00
Alan Donovan 9bf0e215d0 gopls/internal/test/integration/misc: skip asm test unless a{rm,md}64
Fixes golang/go#68058

Change-Id: I8d2467474f39f1834137f5b4718cdbbca4ac0e81
Reviewed-on: https://go-review.googlesource.com/c/tools/+/593416
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-20 12:54:18 +00:00
Alan Donovan 1239d0475f gopls/internal/golang: Hover: use internal pkg doc viewer
This change changes the linksInHover option from bool to
a sum of false | true | "gopls".
The "gopls" setting causes Hover(SynopsisDocumentation)
to generate links to gopls' internal web-based doc viewer.

Thanks to Hana for the idea.

+ Test, release note

Fixes golang/go#67949

Change-Id: I384796780436b191a0711c60085d67363d00e5f6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/572037
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-18 16:54:22 +00:00
Alan Donovan 6ece8fbc64 gopls/internal/golang: improve ergonomics of "Browse documentation"
This change causes the 'Browse documentation...' code action
to offer different pages based on the current selection:
- in an ImportSpec, or a use of the PkgName,
  we display the imported package;
- in a reference to an imported symbol, we display that
  symbol (except for fields, or methods of nonexported types).

The logic that computed the fragment, now extracted to
golang.DocFragment, now also computes an appropriate title.
The various cases of this function are exercised by
a new integration test.

Also, rename s/Render/PkgDoc/ in the integration tests.

Updates golang/go#67949

Change-Id: I7f4b014beca8cfde9ca3540dd10b32e1eb8f95e2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/592577
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-06-18 16:21:21 +00:00
Alan Donovan 693d7febfe gopls/internal/settings: simplify SetOptions
This change simplifies the SetOptions machinery by
eliminating the (public) OptionsResult and Options
types and their methods, and using simpler standalone
functions of these forms:

   setT(dest *T, value any) error
   asT(value any) (T, error)

The code is clearer and significantly shorter.

Details:
- rename SetOptions to Options.Set.
- return only the errors, not the OptionsResults;
  server.handleOptionResult renamed handleOptionErrors.
- remove error result from server.handleOptionResult,
  per preexisting TODO.
- add missing doc comments.
- use JSON terminology in error messages.

Note, minor behavior changes:
- the buildFlags and directoryFilters flags now use
  asStringSlice (per the preexisting TODO), and also
  templateExtensions, but this replaces Sprint(x)
  with asString(x), which is strictly speaking an
  incompatible change.

Change-Id: Ib2169ba8e1db1a34e9bc269e6e8cef3a6763e6e6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/592536
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-17 16:26:12 +00:00
Alan Donovan 6a8bc5fe21 gopls/internal/lsp/source: ignore lambdas in call hierarchy
Previously, anonymous functions were treated as nodes
in the call hierarchy view, but it doesn't make sense to
do so because we have no reliable way to find references
to them, except from within their enclosing function.

So, this change treats anonymous functions and their
enclosing functions as a single item.

Fixes golang/go#64451

Change-Id: I3841adcbad4b13ab190fad58daf38c1bbc6f8baa
Reviewed-on: https://go-review.googlesource.com/c/tools/+/546736
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-06-14 16:28:01 +00:00
Alan Donovan b5dbe8b770 gopls/internal/golang: s/View/Browse/ for browser-based features
We decided "browse" is better than "view" (or last week's "show")
for the UI description, since it connotes "web browser".

Thanks to Dominik Honnef for the idea.

Updates golang/go#67949

Change-Id: If32be800e5c2a0fc50028aad88a00467abe10421
Reviewed-on: https://go-review.googlesource.com/c/tools/+/592496
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-13 20:38:10 +00:00
Rob Findley 2ca6abea0c gopls: expand on documentation about version support changes
Users unfamiliar with the subtleties of version support are rightly
confused by our current documentation. Try to clarify, by defining terms
more precisely and being sure to emphasize that language version support
is unchanged.

Also, add a section for the new stdversions analyzer, which is not
present in gopls@v0.15.x.

For golang/go#67936

Change-Id: Ia9f241da4a67dc0ca82532ae945751ad3c6b6f1f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/592576
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-06-13 20:29:11 +00:00
Alan Donovan db99e8acdb gopls/internal/test/integration/misc: skip ASM assertions on risc64
It appears to be alone in using JAL instead of the CALL instruction.

Fixes golang/go#67960

Change-Id: Ic7002caf418d0ffcf8592f1e255e6c8ea260909b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/592476
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-06-13 17:21:29 +00:00
Rob Findley a852b253a3 gopls/doc/release: update gopls release notes for language support
Update the v0.16.0 release notes to reflect 1.23 support and changes to
our support policy.

For golang/go#67936

Change-Id: I330b8a3897fc3b4b944eb695143042654556dbf1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/592156
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-06-13 16:18:46 +00:00
Michael Stapelberg 03d712539b gopls/doc/emacs.md: use more precise before-save terminology
Change-Id: I7ce5818c2067ae687ce3258189701396a2eea8cb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/592335
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-13 14:36:11 +00:00
Rob Findley f45db9b4bb internal/protocol/command: regenerate commands to fix build
Change-Id: I4744170cc4dcbd4265361dbe3934f6f2080f6d94
Reviewed-on: https://go-review.googlesource.com/c/tools/+/591917
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-06-11 19:05:41 +00:00
Rob Findley 568dea1d0b gopls: update x/telemetry dependency
Change-Id: I0ab009bd9142a2be987f042632bf57713d8b31f8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/591416
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-11 19:02:34 +00:00
Rob Findley 3e9483071c internal/imports: optimize package path filtering
As reported in golang/go#67889, a short unresolved identifier can cause
goimports fixes to be quite slow, because the substring match heuristic
used to filter import paths matches a large fraction of the module
cache.

Fix this by improving the precision of the matching heuristic used to
filter potential packages. We now match only full segments of the import
path (ignoring '.' and '-'), or subsegments delimited by '.' and '-'.

Add a gopls benchmark that reproduces this initial slowness, along with
a command to force a scan of the module cache. On my (overpowered) linux
development machine, with a 5GB module cache, this change reduces the
benchmark time ~90%, from 2s to 200ms. With a smaller machine, slower
operating system, or larger module cache, I imagine the starting
point could be significantly more than 2s.

Fixes golang/go#67889

Change-Id: Id8f7ea20040b059b42366333adeb4add684dee61
Reviewed-on: https://go-review.googlesource.com/c/tools/+/591715
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-06-11 18:12:06 +00:00
ssd71 46928a5cfe gopls: fix StmtToInsertVarBefore for switch stmts
The function StmtToInsertVarBefore on getting a
variable declaration in switch stmt was returning
the variable declaration statement instead of the
switch statment.

Fixes golang/go#67905

Change-Id: Ied1f82061ae4d5bbe6b65e6897e8db44ef43d8c6
GitHub-Last-Rev: 11b8c6d043
GitHub-Pull-Request: golang/tools#498
Reviewed-on: https://go-review.googlesource.com/c/tools/+/591496
Reviewed-by: 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-06-11 16:30:37 +00:00
Alan Donovan 318adf2922 gopls/internal/protocol/command/gen: omit unnecessary MarshalArgs calls
...like we do for Unmarshal.

Change-Id: I2c7ee1f817002c747c429c3fbfb79df3a5cd1a4d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/591955
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-11 16:19:59 +00:00
Alan Donovan bffeaaa266 gopls/internal/golang: s/Show/View/ for web-based reports
All three should be consistent, and "View" connotes a separate
surface more than "Show", which connotes adding annotations to
the current editor view.

Also, rephrase assembly template to encourage upvoting of
the relevant VS Code issue.

Change-Id: I99b07ba347e2023bd672e2b34b13faeece4108db
Reviewed-on: https://go-review.googlesource.com/c/tools/+/591915
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-06-11 15:25:22 +00:00
Rob Findley 82be0b43a9 gopls/internal/server: return a non-nil slice for empty token result
Some clients encounter errors in the presence of a nil semantic tokens
data slice. Since the field is not marked optional, it seems most
appropriate to return a non-nil empty slice when semantic tokens are
disabled.

Fixes golang/go#67885

Change-Id: I85b1e856e0829d73508edae06b373e135340d9ac
Reviewed-on: https://go-review.googlesource.com/c/tools/+/591415
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-06-10 15:05:00 +00:00
Alan Donovan 413a491271 gopls/internal/golang: factor the 3 web reports
This change factors the common elements of the
three reports:

- the common CSS and JS, previously constants,
  are now assets; only the ad hoc styles
  particular to each page remain in the HTML.
- The disconnect banner element is now created on load,
  in common.js, so no <div> HTML is required.
- objHTML, sourceLink are factored out.

Also:
- use the same font-families as pkg.go.dev.
- use addEventListener instead of clobbering window.onload.

Change-Id: Ic21cc46fc8d92a94b78aa1faf5b2f3012f539e57
Reviewed-on: https://go-review.googlesource.com/c/tools/+/591355
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-06-10 14:41:06 +00:00
Alan Donovan f41a407b04 gopls/internal/golang: Web, an abstraction of server.web
This change consolidates the two func types, PosURL and PkgURL,
into an interface, Web, that aligns with the server.web
implementation.

Also, strength-reduce PkgURL to require only a viewID,
not a view (as we did for freesymbolsURL in CL 591157).

Change-Id: Ic48e0d5808257934c56b31126fd4880ee88c7a33
Reviewed-on: https://go-review.googlesource.com/c/tools/+/591318
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-06-10 14:29:05 +00:00
Alan Donovan f5a26d251e gopls/internal/server: simplify FreeSymbols plumbing
Since only a view ID, not a View, is needed, we can simplify
the argument plumbing following the pattern used by Assembly.

Also, rename RenderPackageDoc to PackageDocHTML.

Change-Id: Ib12c26ff0960a3ba96a6b8e6872740dd8767dfbe
Reviewed-on: https://go-review.googlesource.com/c/tools/+/591157
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-10 14:01:41 +00:00
Rob Findley 0341917587 gopls/internal/cache: stop module cache refresh on view shutdown
As described in golang/go#67865, CL 590377 exacerbated a problem that
module cache refreshes may outlive the lifecycle of the view.

Fixes golang/go#67865

Change-Id: Ieafdf6601fee00b6e8ce705502a80224da071578
Reviewed-on: https://go-review.googlesource.com/c/tools/+/591315
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-07 20:58:51 +00:00
Alan Donovan 8f4c6b0bfa gopls/internal/test/integration/misc: fix build
Change-Id: I841144ce85051e4441090ef684beb7865b7273fb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/591316
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2024-06-07 16:18:28 +00:00
Alan Donovan 15d13c3f3f gopls/internal/golang: add "Show assembly of f" code action
This CL adds a new code action to display the Go assembly
code produced for the enclosing function, and all its
nested functions. Each instruction is marked up with a
link that causes cursor navigation in the editor,
using the magic of LSP's showDocument.

Each page load causes a recompile. (A cold build may
take a few seconds in a large project.)

The architecture is determined by the view: for most
files it will be the default GOARCH, but for arch-tagged
files it will be the appropriate one.

+ Test
+ Release note

Fixes golang/go#67478

Change-Id: I51285215e9b27c510076c64eeb7b7ae3899f8a59
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588395
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-07 15:40:13 +00:00
Alan Donovan a35b054a18 gopls/internal/test/integration: style tweaks to CodeAction
Details:
- Pass TriggerKind by value, not pointer.
  Define nil and zero as equivalent, always.
  Name the zero value: UnknownTrigger.
  Omit "kind" suffix in var names for brevity.
- Add Workdir.EntireFile(path string) Location helper.
- Env.CodeAction renamed CodeActionForFile.
  Env.CodeAction0 unsuffixed.
  Editor.CodeAction deleted.
  Editor.CodeAction0 unsuffixed.
- Restore lost commentary.

(Sorry, I was late to the code review of CL 590935.)

Change-Id: I3fbe3e4e7567366b0742dcec44dc50539b9e9621
Reviewed-on: https://go-review.googlesource.com/c/tools/+/591176
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
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-07 15:21:21 +00:00
Alan Donovan fc82f4e5a0 gopls/internal/protocol/command: use gopls.foo form everywhere
Before, the command.Command enum values (e.g. "run_tests") did
not match the actual command strings used in the Command field
of protocol.Command (e.g. "gopls.run_tests").

This change causes us to use the "gopls."-prefixed form everywhere,
avoiding the need for various conversions, and the opportunity
to forget to make them.

Also
- tidy up the commands.md markdown.
- remove 2x TODOs about eliminating Command.Title:
  I think it works nicely in the documentation.
- remove ⬤ blobs from markdown by popular demand.

Change-Id: Ida5981ba834ea148fa0267319cf874b9a48c9289
Reviewed-on: https://go-review.googlesource.com/c/tools/+/591175
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-07 14:44:27 +00:00
Alan Donovan c24ae10e7b gopls/internal/cmd: cleanup progress handling
This CL adds connection.registerProgressHandler so that
each call to, say, executeCommand can temporarily install
a handler for progress notifications bearing the token
passed to executeCommand.

However, the initial workspace load must be treated a little
specially since it occurs during the initialize RPC, which
happens before the newConnection constructor has returned.
So, tracking the IWL is now a core feature of connection
instead of something local to the 'stats' subcommand.

Also, make the "asynchronous" property a declarative
attribute of each command.Command so that both the server
and the client can do the right thing--start a thread,
wait for the 'end' notification--based on the metadata.

Also:
- use connection.executeCommand in all cases instead of
  direct call to ExecuteCommand.
- merge Application.connect{,remote} and factor common logic.

Change-Id: If7a000593ef4d4dc5658423a03c56b2f4f3a06ca
Reviewed-on: https://go-review.googlesource.com/c/tools/+/591095
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-07 14:36:04 +00:00
Suzy Mueller 6e3b208b98 gopls/internal/test: add test case for parameter rename match import
This adds a test case to verify that valid renamings can occur, when
the new name of a parameter is identical to an imported package, even
when referenced by a function paramater.

The bug where the rename was failing is fixed when using go1.22. The
new go version fills in a missing Pos for an object scope that allows
LookupPos to correctly determine if the scope is relevant.

For golang/go#57479

Change-Id: Ifebafb78483f174eac94cd1ec5ac68db9e88684f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/590976
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-06-06 20:08:44 +00:00
Hana (Hyang-Ah) Kim 5e0f1d8dc3 gopls/internal/server: fix regression in organize imports code action
CL 587555 suppressed some code actions if the request was triggered
automatically, but that was too invasive and suppressed useful code
actions like quick fixes and organize imports. Maybe some refactoring
code actions and source.* actions can be also useful enough to be
presented in the light bulb menu.

Partially revert CL 587555, by suppress only refactor.inline code
action if the user's intention is not refactoring
(e.g. cursor move around a function call). However, if the user
selected a code area (function name), that is likely an action for
refactoring, so continue to present refactor.inline in the light bulb
menu.

Fixes golang/go#67823
Fixes golang/go#65167

Change-Id: I2d4a3d92199e501103596d0aed78ece34760149f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/590935
Auto-Submit: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-06 18:30:51 +00:00
Rob Findley 8bf61b85c2 gopls/internal/cache: fix module resolver cache refreshing
An apparent bad merge in CL 561235 caused the critical component--
clearing the resolver for a new scan--to be dropped. Fix this, so that
the imports state is actually refreshed asynchronously.

It is surprising that this was not reported, though I see perhaps two
related comments in survey results. Most likely adding a new import is
infrequent enough that users were simply confused, or learned to restart
gopls (alas).

Also, add more instrumentation that would help debug golang/go#67289.

For golang/go#67289

Change-Id: I50d70a470eb393caf9e0b41856997942372b216f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/590377
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-06-05 19:29:32 +00:00
toad 7522327277 gopls/rename: Fix spurious package name conflicts.
Fixes golang/go#67069

Change-Id: I537308c8941a5f2f2c6e10791e75b529574d170b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/586336
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>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-06-05 18:30:24 +00:00
Alan Donovan 5e43887ecb internal/stdlib: generate from api/next/*.txt (go1.23) too
This CL causes the generator to treat the next/*.txt files
as if they comprise the next (e.g. go1.23.txt) manifest,
which doesn't exist until close to the release (specifically,
between the start of the freeze and the first release
candidate).

Change-Id: I84158032484d5aa4b1d2d57c11209a24e6924b5e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/590355
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-04 18:08:40 +00:00
Gopher Robot bc6931db37 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: If9b44decd91eb9cf6e5541ee75aff761d3a46a8b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/590415
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-06-04 17:56:46 +00:00
Rob Findley 018d3b2768 gopls: warn about Go 1.19 and Go 1.20
Update the support table to warn when users install gopls with Go 1.19
or 1.20, or have these older Go versions in their PATH.
Clarify current and future support in the README.

Fixes golang/go#50825
Updates golang/go#65917

Change-Id: I99de1a7717a8cf99cae1a561ced63e9724dfff66
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588763
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2024-06-03 16:17:05 +00:00
Alan Donovan 58cc8a4458 gopls/internal/filecache: suppress gc in tests
Now that our CI builds (have for some time) set
an explicit GOPLSCACHE, it's not necessary for
tests to run the filecache GC, and it is costly
since they all try to do so at once.

This CL rotates the main loop so the first GC
doesn't start until after 5m, by which time the
tests are done.

This improves the real time of the integration
tests on macOS by about 8%.

n=3
before: 	119 115 117 mean=117s real
after: 		104 107 111 mean=107s real

Change-Id: I5eddb850795976e4a9fde33b0fc909e3d8e87169
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588768
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-03 13:17:58 +00:00
Alan Donovan b6235391ad gopls/internal/cache: suppress "internal" import check on Bazel
The go command treats imports of packages whose path contains
"/internal/" specially, and gopls must simulate it in several
places. However, other build systems such as Bazel have their
own mechanisms for representing visibility.

This CL suppresses the check for packages obtained from a
build system other than go list. (We derive this information
from the view type, which in turn simulates the go/packages
driver protocol switch using $GOPACKAGESDRIVER, etc.)

Added test using Rob's new pass-through gopackagesdriver.

Fixes golang/go#66856

Change-Id: I6e0671caeabe2146d397eb56d5cd4f7a40384370
Reviewed-on: https://go-review.googlesource.com/c/tools/+/587931
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-31 21:21:43 +00:00
Rob Findley 3c293ad67a internal/cache: invalidate broken imports when package files change
When a file->package association changes, it may fix broken imports.
Fix this invalidation in Snapshot.clone.

Fixes golang/go#66384

Change-Id: If0f491548043a30bb6302bf207733f6f458f2574
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588764
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-31 20:31:12 +00:00
Rob Findley 5eff1eeb9f gopls/internal/cache: check viewMap before altering views
The bug report in golang/go#67144 likely means that we got a change
notification after the session was shut down (and thus s.viewMap was
nil).

Fix this by being more rigorous in guarding any function that resets
s.viewMap with a check for s.viewMap != nil. Also, refactor to remove
the confusing updateViewLocked and dropView functions, which obscure the
logic of their callers.

Fixes golang/go#67144

Change-Id: Ic76ae56fa631f6a7b11709437ad74a2897d1e537
Reviewed-on: https://go-review.googlesource.com/c/tools/+/589456
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-05-31 20:31:05 +00:00
Rob Findley 4669dc77ee gopls/internal/test/marker: simplify seedCache file
Simplify the file used to seed the marker test cache, as suggested in CL
588940.

Change-Id: I421a3e013fcc17f2c6ab2ff5c269e6f360ca9d6e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588942
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-05-30 19:32:06 +00:00
Rob Findley 6887e998b2 gopls/internal/cache: use a better view in viewOfLocked
The 'bestView' function was used in two places, where the meaning of
'best' differed. When re-evaluating view definitions in selectViewDefs,
we may want to create a new view if none of them matched build tags.
When operating on a file in viewOfLocked, we want to choose the most
relevant view out of the existing view definitions.

In golang/go#60776, we see that the latter concern was poorly handled by
the 'bestView' abstraction. Returning nil was not, in fact, best,
because it resulted in the file being associated with the default AdHoc
view, which doesn't know about modules.

Refactor so that viewOfLocked chooses the most relevant view, even if
none match build tags. This causes the orphaned file diagnostic to more
accurately report that the file is excluded due to build tags.

Fixes golang/go#60776

Change-Id: I40f236b3b63468faa1dfe6ae6aeac590c952594f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588941
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-05-30 19:19:34 +00:00
Rob Findley bd624fd45d gopls: make tests tolerant of new go/types error format
CL 589118 is changing the format of go/types errors.

Update tests and the unusedvariable analyzer to be tolerant of this new
format.

For golang/go#67685

Change-Id: Ic1d3e663973edac3dcc6d0d6cc512fffd595eeb2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/589455
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-05-30 18:26:36 +00:00
Rob Findley 8d54ca127f gopls/internal/test/marker: seed the cache before running tests
The marker tests are heavily parallelized, and many import common
standary library packages. As a result, depending on concurrency, they
perform a LOT of duplicate type checking and analysis.

Seeding the cache before running the tests resulted in an ~80% decrease
in CPU time on my workstation, from ~250s to ~50s, which is close to the
~40s of CPU time observed on the second invocation, which has a cache
seeded by the previous run. I also observed a ~33% decrease in run time.
Admittedly my workstation has 48 cores, and so I'd expect less of an
improvement on smaller machines.

Change-Id: Ied15062aa8d847a887cc8293c37cb3399e7a82b6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588940
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2024-05-30 16:14:22 +00:00
Robert Findley 01018ba9ed Revert "gopls/internal/settings: enable semantic tokens by default"
This reverts CL 579337.

Reason for revert: need more work on staging this change in VS Code.

Change-Id: I82eea17f96a0365bd616ee2617536f10869e08f2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/589060
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2024-05-30 12:59:04 +00:00
Alan Donovan 019da392d7 gopls/internal/golang: OutgoingCalls: fix crash on unsafe.Slice
Also, audit the golang package for similar places where we
discriminate builtins, and make them all use the new isBuiltin
helper, which is based on lack of a position instead of messing
around with pkg==nil||pkg==types.Unsafe||...
"A symbol without a position" is a fair definition of a built-in.

Fixes golang/go#66923

Change-Id: I7f94b8d0f865f8c079f1164fd61121eefbb40522
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588937
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-05-29 22:47:42 +00:00
Rob Findley 30c880d92f gopls/internal/cache: improve missing import error message
Make the missing import error knowledgeable of the view type, so that it
can correctly reference modules, GOROOT, GOPATH, or go/packages driver
as applicable.

While at it, fix some duplicated and broken logic for determining if the
view is in go/packages driver mode, consolidate on representing the
driver accurately as GoEnv.EffectiveGOPACKAGESDRIVER.

Fixes golang/go#64980

Change-Id: I7961aade981173098ab02cbe1862ac2eca2c394b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/589215
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-05-29 22:32:04 +00:00
Rob Findley f10a0f1c3b gopls/internal/golang: skip TestFreeRefs on js
This test was (surprisingly) the only source of failure on js/wasm. Skip
it to keep the build dashboard clean.

Change-Id: I69aa5b91152c313b5dba7d13a76fd6d32cd159a9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588755
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2024-05-28 17:35:58 +00:00
Hana (Hyang-Ah) Kim d940b33567 gopls/internal/server: support InsertReplaceEdit completion
Many editors support two different operations when accepting
a completion item: insert and replace. LSP 3.16 introduced support
for both using `InsertReplaceEdit`. For clients that declare
textDocument.completion.insertReplaceSupport capability, gopls
can provide both insert/repace mode text edits.

See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItem

VS Code client supports this capability, and users can switch
the mode with the editor.suggest.insertMode setting.
Note that in VS Code, "insert" is the default. That means,
providing a different range for insert changes the
user-perceived completion behavior greatly.

To reduce potential regression, this CL sets a different range
for insert only if all of the following conditions are met:

   * there is a surrounding identifier token for the position.
   * when splitting the identifier surrounding the position
     to prefix and suffix, the suffix is not empty.
   * the suffix is not part of the candidate's insert text,
     which means the suffix may be deleted in replace mode.

Fixes golang/vscode-go#3365
Fixes golang/go#61215

Change-Id: Ibe2476ddb9c13ecbaca7fb88cb3564912c4e5f4a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/585275
Auto-Submit: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-28 17:19:42 +00:00
Alan Donovan e635bfa66b gopls/internal/golang: unexport more declarations
I missed a few in my previous CL:
- FindParam
- ParamInfo and its fields
- TestFn
- TestFns (eliminated entirely)

Change-Id: Ib8dabba73e679be5842bf1af359db80157446993
Reviewed-on: https://go-review.googlesource.com/c/tools/+/587932
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-05-28 15:48:05 +00:00
Alan Donovan e1b14a1915 gopls/internal/server: avoid VS Code lightbulb
VS Code has a complex and undocumented logic for presenting
Code Actions of various kinds in the user interface.
This CL documents the empirically observed behavior at
CodeActionKind.

Previously, users found that "nearly always available"
code actions such as "Inline call to f" were a distracting
source of lightbulb icons in the UI. This change suppresses
non-diagnostic-associated Code Actions (such as "Inline call")
when the CodeAction request does not have TriggerKind=Invoked.
(Invoked means the CodeAction request was caused by opening
a menu, as opposed to mere cursor motion.)

Also, rename BundleQuickFixes et al using "lazy" instead
of "quick" as QuickFix has a different special meaning
and lazy fixes do not necesarily have kind "quickfix"
(though all currently do).

Fixes golang/go#65167
Update golang/go#40438

Change-Id: I83563e1bb476e56a8404443d7e48b7c240bfa2e0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/587555
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-05-24 14:37:47 +00:00
Rob Findley 34db5bc3c8 gopls: initial support for godebug directive in go.mod and go.work
For now, incorporate godebug support by just updating x/mod and write
some tests. Diagnostics are mispositioned due to golang/go#67623.

While writing tests, I realized that the expect package still did not
support go.work files. Add this missing support. Also, remove a stale
comment from go.mod comment extraction, and simplify.

Fixes golang/go#67583

Change-Id: I9d9bb53824b8c817ee18f51a0cfca63842565513
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588055
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-24 13:57:01 +00:00
Alan Donovan 56f50e32fb gopls/doc: split codelenses out of settings
This CL splits codelenses.md out of settings.md, since
they aren't settings.

This reduces the indentation level of settings by one,
since we can dispense with a heading. Also, don't increase
the <h%d> nesting level for each level of nested dotted options:
ui.foo.bar should not be rendered smaller than ui.foo.
Use only h2 for groupings and h3 for settings.

Also:
- improve the introduction.
- add anchors for groupings.
- delete handwritten .md doc for obsolete newDiff setting.
- add TODOs for some existing bugs in the generator.

Change-Id: If6e7fff028b2c372e0d766d3d092bd0e41d61486
Reviewed-on: https://go-review.googlesource.com/c/tools/+/586879
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-05-24 01:10:53 +00:00
Alan Donovan 3629652b9d gopls/internal/analysis/simplifyrange: suppress on range-over-func
go1.23's range-over-func currently requires all the vars be
declared, blank if necessary. That may change, but for now,
suppress the checker.

Fixes golang/go#67239
Updates golang/go#65236

Change-Id: I3e783fcfcb6a6f01f3acf62428cd9accbeb160c1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588056
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>
Commit-Queue: Alan Donovan <adonovan@google.com>
2024-05-24 00:39:57 +00:00
Hana (Hyang-Ah) Kim fb52877ad2 all: sync golang.org/x/telemetry@bda5523
Picks up bug fix CL 586098 and CL 586195.

Change-Id: Idc8b0c7f6b5202ae3ade4bcdf7349725a3c01eef
Reviewed-on: https://go-review.googlesource.com/c/tools/+/587196
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
2024-05-22 19:28:01 +00:00
Hana (Hyang-Ah) Kim 4646dbf8ef gopls/internal/protocol: customize InsertReplaceEdit JSON unmarshal
InsertReplaceEdit is used instead of TextEdit in CompletionItem
in editors that support it. These two types are alike in appearance
but can be differentiated by the presence or absence of
certain properties. UnmarshalJSON of the sum type tries to
unmarshal as TextEdit only if unmarshal as InsertReplaceEdit fails.
Due to this similarity, unmarshal with the different type never fails.

Add a custom JSON unmarshaller for InsertReplaceEdit,
so it fails when the required fields are missing. That makes
Or_CompletionItem_textEdit decode TextEdit type correctly.

For golang/go#40871
For golang/go#61215

Change-Id: I62471fa973fa376cad5eb3934522ff21c14e3647
Reviewed-on: https://go-review.googlesource.com/c/tools/+/587135
Reviewed-by: Peter Weinberger <pjw@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-22 18:44:40 +00:00
Alan Donovan bc5e086cf2 gopls/internal/golang: unexport several functions
All of these functions are no longer referenced across
packages since we cleaned up the server/lsprpc/golang split.

CanExtractVariable
EmbedDefinition
EnclosingStaticCall
FormatNodeFile
LinknameDefinition
CanExtractFunction

Updates golang/go#67573

Change-Id: I18490b333d79bad83eb5fcc34688fb41381771d1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/586781
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-05-22 16:46:20 +00:00