You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gopls/internal/golang: make GCDetails a code action, not a code lens
Before, GCDetails was a code lens source that annotated the package
declaration of each file with a command. The command, gopls.gc_details,
toggles the per-package flag that controls whether Go compiler
optimization details are reported as diagnostics.
Code lenses are poorly supported across editors, and this code lens
was disabled by default (presumably because VS Code has an alternative
custom client-side command to toggle the flag).
This change changes the command from being a code lens to code action,
offered for any selection in the file; the mechanism of toggling the
flag (the gopls.gc_details command) is unchanged, though the redundant
ToggleGCDetails command has been eliminated.
This change should make it easier for users in a range of
editors to both discover and use this useful feature.
The new nomenclature avoids "GC" (the old name for the Go compiler,
easily confused with "garbage collector"), and instead uses
"Toggle compiler optimization details" consistently.
(The one exception is the string value of the command, whose name must
not be changed since it would break the VS Code client side logic.)
+ Test, relnote, docs
Change-Id: If05f1945914d763396fb9a7626d97e3802a7acbc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/639255
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Robert Findley <[email protected]>
Auto-Submit: Alan Donovan <[email protected]>
Commit-Queue: Alan Donovan <[email protected]>
Copy file name to clipboardExpand all lines: gopls/internal/doc/api.json
+3-15
Original file line number
Diff line number
Diff line change
@@ -638,7 +638,7 @@
638
638
{
639
639
"Name": "annotations",
640
640
"Type": "map[enum]bool",
641
-
"Doc": "annotations specifies the various kinds of optimization diagnostics\nthat should be reported by the gc_details command.\n",
641
+
"Doc": "annotations specifies the various kinds of compiler\noptimization details that should be reported as diagnostics\nwhen enabled for a package by the \"Toggle compiler\noptimization details\" (`gopls.gc_details`) command.\n",
642
642
"EnumKeys": {
643
643
"ValueType": "bool",
644
644
"Keys": [
@@ -791,15 +791,10 @@
791
791
{
792
792
"Name": "codelenses",
793
793
"Type": "map[enum]bool",
794
-
"Doc": "codelenses overrides the enabled/disabled state of each of gopls'\nsources of [Code Lenses](codelenses.md).\n\nExample Usage:\n\n```json5\n\"gopls\": {\n...\n\"codelenses\": {\n\"generate\": false, // Don't show the `go generate` lens.\n\"gc_details\": true // Show a code lens toggling the display of gc's choices.\n}\n...\n}\n```\n",
794
+
"Doc": "codelenses overrides the enabled/disabled state of each of gopls'\nsources of [Code Lenses](codelenses.md).\n\nExample Usage:\n\n```json5\n\"gopls\": {\n...\n\"codelenses\": {\n\"generate\": false, // Don't show the `go generate` lens.\n }\n...\n}\n```\n",
795
795
"EnumKeys": {
796
796
"ValueType": "bool",
797
797
"Keys": [
798
-
{
799
-
"Name": "\"gc_details\"",
800
-
"Doc": "`\"gc_details\"`: Toggle display of Go compiler optimization decisions\n\nThis codelens source causes the `package` declaration of\neach file to be annotated with a command to toggle the\nstate of the per-session variable that controls whether\noptimization decisions from the Go compiler (formerly known\nas \"gc\") should be displayed as diagnostics.\n\nOptimization decisions include:\n- whether a variable escapes, and how escape is inferred;\n- whether a nil-pointer check is implied or eliminated;\n- whether a function can be inlined.\n\nTODO(adonovan): this source is off by default because the\nannotation is annoying and because VS Code has a separate\n\"Toggle gc details\" command. Replace it with a Code Action\n(\"Source action...\").\n",
801
-
"Default": "false"
802
-
},
803
798
{
804
799
"Name": "\"generate\"",
805
800
"Doc": "`\"generate\"`: Run `go generate`\n\nThis codelens source annotates any `//go:generate` comments\nwith commands to run `go generate` in this directory, on\nall directories recursively beneath this one.\n\nSee [Generating code](https://go.dev/blog/generate) for\nmore details.\n",
"Title": "Toggle display of Go compiler optimization decisions",
935
-
"Doc": "\nThis codelens source causes the `package` declaration of\neach file to be annotated with a command to toggle the\nstate of the per-session variable that controls whether\noptimization decisions from the Go compiler (formerly known\nas \"gc\") should be displayed as diagnostics.\n\nOptimization decisions include:\n- whether a variable escapes, and how escape is inferred;\n- whether a nil-pointer check is implied or eliminated;\n- whether a function can be inlined.\n\nTODO(adonovan): this source is off by default because the\nannotation is annoying and because VS Code has a separate\n\"Toggle gc details\" command. Replace it with a Code Action\n(\"Source action...\").\n",
0 commit comments