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.
Fixesgolang/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>
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.
Fixesgolang/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>
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>
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>
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>
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>
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>
The message is now of the form "Add cases for pkg.Type" when
the type is imported from another package.
Fixesgolang/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>
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.
Fixesgolang/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>
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>
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.
Fixesgolang/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>
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>
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>
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>
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 '@'.
Fixesgolang/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>
(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>
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>
As the existing comment attests, this can happen in the wild.
Just skip it and move on.
+ a test
Fixesgolang/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>
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>
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>
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>
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.
Fixesgolang/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>
(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>
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>
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>
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.
Fixesgolang/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>
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.
Fixesgolang/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>
Add skips as appropriate to TestFreeRefs and TestDriverConformance.
Also add a skip for a preexisting failure on wasip1: golang/go#64725.
Fixesgolang/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>
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>
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.
Fixesgolang/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>
The package path in a /pkg URL does not want a module
version suffix: the view specifies the versions of all packages.
Remove them.
Fixesgolang/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>
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.
Fixesgolang/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>
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>
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>
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>
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>
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>
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>
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>
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.
Fixesgolang/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>
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
Fixesgolang/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>
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>
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>
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.
Fixesgolang/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>
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>
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>
It appears to be alone in using JAL instead of the CALL instruction.
Fixesgolang/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>
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>
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>
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.
Fixesgolang/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>
The function StmtToInsertVarBefore on getting a
variable declaration in switch stmt was returning
the variable declaration statement instead of the
switch statment.
Fixesgolang/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>
...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>
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>
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.
Fixesgolang/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>
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>
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>
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>
As described in golang/go#67865, CL 590377 exacerbated a problem that
module cache refreshes may outlive the lifecycle of the view.
Fixesgolang/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>
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
Fixesgolang/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>
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>
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>
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>
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>
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.
Fixesgolang/go#67823Fixesgolang/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>
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>
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>
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.
Fixesgolang/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>
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>
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.
Fixesgolang/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>
When a file->package association changes, it may fix broken imports.
Fix this invalidation in Snapshot.clone.
Fixesgolang/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>
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.
Fixesgolang/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>
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>
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.
Fixesgolang/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>
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>
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>
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>
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.
Fixesgolang/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>
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.
Fixesgolang/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>
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>
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.
Fixesgolang/vscode-go#3365Fixesgolang/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>
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>
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).
Fixesgolang/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>
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.
Fixesgolang/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>
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>
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.
Fixesgolang/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>
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>
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>