internal/lsp: switch to the new command API

Fully switch to the new generated command API, and remove the old
dynamic command configuration.

This involved several steps:
 + Switch the command dispatch in internal/lsp/command.go to go through
   the command package. This means that all commands must now use the new
   signature.
 + Update commandHandler to use the new command signatures.
 + Fix some errors discovered in the command interface now that we're
   actually using it.
 + Regenerate bindings.
 + Update all code lens and suggested fixes to new the new command
   constructors.
 + Generate values in the command package to hold command names and the
   full set of commands, so that they may be referenced by name.
 + Update any references to command names to use the command package.
 + Delete command metadata from the source package. Rename command.go to
   fix.go.
 + Update lsp tests to execute commands directly rather than use an
   internal API. This involved a bit of hackery to collect the edits.
 + Update document generation to use command metadata. Documenting the
   arguments is left to a later CL.
 + Various small fixes related to the above.

This change is intended to be invisible to users. We have changed the
command signatures, but have not (previously) committed to backwards
compatibility for commands. Notably, the gopls.test and gopls.gc_details
signatures are preserved, as these are the two cases where we are aware
of LSP clients calling them directly, not from a code lens or
diagnostic.

For golang/go#40438

Change-Id: Ie1b92c95d6ce7e2fc25fc029d1f85b942f40e851
Reviewed-on: https://go-review.googlesource.com/c/tools/+/290111
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
diff --git a/internal/lsp/source/api_json.go b/internal/lsp/source/api_json.go
index 8a13428..1da2ccd 100755
--- a/internal/lsp/source/api_json.go
+++ b/internal/lsp/source/api_json.go
@@ -577,37 +577,37 @@
 					Keys: []EnumKey{
 						{
 							Name:    "\"gc_details\"",
-							Doc:     "gc_details controls calculation of gc annotations.\n",
+							Doc:     "Toggle the calculation of gc annotations.",
 							Default: "false",
 						},
 						{
 							Name:    "\"generate\"",
-							Doc:     "generate runs `go generate` for a given directory.\n",
+							Doc:     "Runs `go generate` for a given directory.",
 							Default: "true",
 						},
 						{
 							Name:    "\"regenerate_cgo\"",
-							Doc:     "regenerate_cgo regenerates cgo definitions.\n",
+							Doc:     "Regenerates cgo definitions.",
 							Default: "true",
 						},
 						{
 							Name:    "\"test\"",
-							Doc:     "test runs `go test` for a specific test function.\n",
+							Doc:     "Runs `go test` for a specific set of test or benchmark functions.",
 							Default: "false",
 						},
 						{
 							Name:    "\"tidy\"",
-							Doc:     "tidy runs `go mod tidy` for a module.\n",
+							Doc:     "Runs `go mod tidy` for a module.",
 							Default: "true",
 						},
 						{
 							Name:    "\"upgrade_dependency\"",
-							Doc:     "upgrade_dependency upgrades a dependency.\n",
+							Doc:     "Upgrades a dependency in the go.mod file for a module.",
 							Default: "true",
 						},
 						{
 							Name:    "\"vendor\"",
-							Doc:     "vendor runs `go mod vendor` for a module.\n",
+							Doc:     "Runs `go mod vendor` for a module.",
 							Default: "true",
 						},
 					},
@@ -675,124 +675,119 @@
 		{
 			Command: "gopls.add_dependency",
 			Title:   "Add dependency",
-			Doc:     "add_dependency adds a dependency.\n",
+			Doc:     "Adds a dependency to the go.mod file for a module.",
+		},
+		{
+			Command: "gopls.apply_fix",
+			Title:   "Apply a fix",
+			Doc:     "Applies a fix to a region of source code.",
 		},
 		{
 			Command: "gopls.check_upgrades",
 			Title:   "Check for upgrades",
-			Doc:     "check_upgrades checks for module upgrades.\n",
-		},
-		{
-			Command: "gopls.extract_function",
-			Title:   "Extract to function",
-			Doc:     "extract_function extracts statements to a function.\n",
-		},
-		{
-			Command: "gopls.extract_variable",
-			Title:   "Extract to variable",
-			Doc:     "extract_variable extracts an expression to a variable.\n",
-		},
-		{
-			Command: "gopls.fill_struct",
-			Title:   "Fill struct",
-			Doc:     "fill_struct is a gopls command to fill a struct with default\nvalues.\n",
+			Doc:     "Checks for module upgrades.",
 		},
 		{
 			Command: "gopls.gc_details",
 			Title:   "Toggle gc_details",
-			Doc:     "gc_details controls calculation of gc annotations.\n",
+			Doc:     "Toggle the calculation of gc annotations.",
 		},
 		{
 			Command: "gopls.generate",
 			Title:   "Run go generate",
-			Doc:     "generate runs `go generate` for a given directory.\n",
+			Doc:     "Runs `go generate` for a given directory.",
 		},
 		{
 			Command: "gopls.generate_gopls_mod",
 			Title:   "Generate gopls.mod",
-			Doc:     "generate_gopls_mod (re)generates the gopls.mod file.\n",
+			Doc:     "(Re)generate the gopls.mod file for a workspace.",
 		},
 		{
 			Command: "gopls.go_get_package",
 			Title:   "go get package",
-			Doc:     "go_get_package runs `go get` to fetch a package.\n",
+			Doc:     "Runs `go get` to fetch a package.",
 		},
 		{
 			Command: "gopls.regenerate_cgo",
 			Title:   "Regenerate cgo",
-			Doc:     "regenerate_cgo regenerates cgo definitions.\n",
+			Doc:     "Regenerates cgo definitions.",
 		},
 		{
 			Command: "gopls.remove_dependency",
 			Title:   "Remove dependency",
-			Doc:     "remove_dependency removes a dependency.\n",
+			Doc:     "Removes a dependency from the go.mod file of a module.",
+		},
+		{
+			Command: "gopls.run_tests",
+			Title:   "Run test(s)",
+			Doc:     "Runs `go test` for a specific set of test or benchmark functions.",
 		},
 		{
 			Command: "gopls.test",
-			Title:   "Run test(s)",
-			Doc:     "test runs `go test` for a specific test function.\n",
+			Title:   "Run test(s) (legacy)",
+			Doc:     "Runs `go test` for a specific set of test or benchmark functions.",
 		},
 		{
 			Command: "gopls.tidy",
 			Title:   "Run go mod tidy",
-			Doc:     "tidy runs `go mod tidy` for a module.\n",
+			Doc:     "Runs `go mod tidy` for a module.",
 		},
 		{
-			Command: "gopls.undeclared_name",
-			Title:   "Undeclared name",
-			Doc:     "undeclared_name adds a variable declaration for an undeclared\nname.\n",
+			Command: "gopls.toggle_gc_details",
+			Title:   "Toggle gc_details",
+			Doc:     "Toggle the calculation of gc annotations.",
 		},
 		{
 			Command: "gopls.update_go_sum",
 			Title:   "Update go.sum",
-			Doc:     "update_go_sum updates the go.sum file for a module.\n",
+			Doc:     "Updates the go.sum file for a module.",
 		},
 		{
 			Command: "gopls.upgrade_dependency",
 			Title:   "Upgrade dependency",
-			Doc:     "upgrade_dependency upgrades a dependency.\n",
+			Doc:     "Upgrades a dependency in the go.mod file for a module.",
 		},
 		{
 			Command: "gopls.vendor",
 			Title:   "Run go mod vendor",
-			Doc:     "vendor runs `go mod vendor` for a module.\n",
+			Doc:     "Runs `go mod vendor` for a module.",
 		},
 	},
 	Lenses: []*LensJSON{
 		{
 			Lens:  "gc_details",
 			Title: "Toggle gc_details",
-			Doc:   "gc_details controls calculation of gc annotations.\n",
+			Doc:   "Toggle the calculation of gc annotations.",
 		},
 		{
 			Lens:  "generate",
 			Title: "Run go generate",
-			Doc:   "generate runs `go generate` for a given directory.\n",
+			Doc:   "Runs `go generate` for a given directory.",
 		},
 		{
 			Lens:  "regenerate_cgo",
 			Title: "Regenerate cgo",
-			Doc:   "regenerate_cgo regenerates cgo definitions.\n",
+			Doc:   "Regenerates cgo definitions.",
 		},
 		{
 			Lens:  "test",
-			Title: "Run test(s)",
-			Doc:   "test runs `go test` for a specific test function.\n",
+			Title: "Run test(s) (legacy)",
+			Doc:   "Runs `go test` for a specific set of test or benchmark functions.",
 		},
 		{
 			Lens:  "tidy",
 			Title: "Run go mod tidy",
-			Doc:   "tidy runs `go mod tidy` for a module.\n",
+			Doc:   "Runs `go mod tidy` for a module.",
 		},
 		{
 			Lens:  "upgrade_dependency",
 			Title: "Upgrade dependency",
-			Doc:   "upgrade_dependency upgrades a dependency.\n",
+			Doc:   "Upgrades a dependency in the go.mod file for a module.",
 		},
 		{
 			Lens:  "vendor",
 			Title: "Run go mod vendor",
-			Doc:   "vendor runs `go mod vendor` for a module.\n",
+			Doc:   "Runs `go mod vendor` for a module.",
 		},
 	},
 	Analyzers: []*AnalyzerJSON{