golang.org/x/tools/gopls@v0.15.3/internal/protocol/command/command_gen.go (about) 1 // Copyright 2021 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Don't include this file during code generation, or it will break the build 6 // if existing interface methods have been modified. 7 //go:build !generate 8 // +build !generate 9 10 // Code generated by gen.go. DO NOT EDIT. 11 12 package command 13 14 import ( 15 "context" 16 "fmt" 17 18 "golang.org/x/tools/gopls/internal/protocol" 19 ) 20 21 // Symbolic names for gopls commands, excluding "gopls." prefix. 22 // These commands may be requested by ExecuteCommand, CodeLens, 23 // CodeAction, and other LSP requests. 24 const ( 25 AddDependency Command = "add_dependency" 26 AddImport Command = "add_import" 27 AddTelemetryCounters Command = "add_telemetry_counters" 28 ApplyFix Command = "apply_fix" 29 ChangeSignature Command = "change_signature" 30 CheckUpgrades Command = "check_upgrades" 31 DiagnoseFiles Command = "diagnose_files" 32 EditGoDirective Command = "edit_go_directive" 33 FetchVulncheckResult Command = "fetch_vulncheck_result" 34 GCDetails Command = "gc_details" 35 Generate Command = "generate" 36 GoGetPackage Command = "go_get_package" 37 ListImports Command = "list_imports" 38 ListKnownPackages Command = "list_known_packages" 39 MaybePromptForTelemetry Command = "maybe_prompt_for_telemetry" 40 MemStats Command = "mem_stats" 41 RegenerateCgo Command = "regenerate_cgo" 42 RemoveDependency Command = "remove_dependency" 43 ResetGoModDiagnostics Command = "reset_go_mod_diagnostics" 44 RunGoWorkCommand Command = "run_go_work_command" 45 RunGovulncheck Command = "run_govulncheck" 46 RunTests Command = "run_tests" 47 StartDebugging Command = "start_debugging" 48 StartProfile Command = "start_profile" 49 StopProfile Command = "stop_profile" 50 Test Command = "test" 51 Tidy Command = "tidy" 52 ToggleGCDetails Command = "toggle_gc_details" 53 UpdateGoSum Command = "update_go_sum" 54 UpgradeDependency Command = "upgrade_dependency" 55 Vendor Command = "vendor" 56 Views Command = "views" 57 WorkspaceStats Command = "workspace_stats" 58 ) 59 60 var Commands = []Command{ 61 AddDependency, 62 AddImport, 63 AddTelemetryCounters, 64 ApplyFix, 65 ChangeSignature, 66 CheckUpgrades, 67 DiagnoseFiles, 68 EditGoDirective, 69 FetchVulncheckResult, 70 GCDetails, 71 Generate, 72 GoGetPackage, 73 ListImports, 74 ListKnownPackages, 75 MaybePromptForTelemetry, 76 MemStats, 77 RegenerateCgo, 78 RemoveDependency, 79 ResetGoModDiagnostics, 80 RunGoWorkCommand, 81 RunGovulncheck, 82 RunTests, 83 StartDebugging, 84 StartProfile, 85 StopProfile, 86 Test, 87 Tidy, 88 ToggleGCDetails, 89 UpdateGoSum, 90 UpgradeDependency, 91 Vendor, 92 Views, 93 WorkspaceStats, 94 } 95 96 func Dispatch(ctx context.Context, params *protocol.ExecuteCommandParams, s Interface) (interface{}, error) { 97 switch params.Command { 98 case "gopls.add_dependency": 99 var a0 DependencyArgs 100 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 101 return nil, err 102 } 103 return nil, s.AddDependency(ctx, a0) 104 case "gopls.add_import": 105 var a0 AddImportArgs 106 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 107 return nil, err 108 } 109 return nil, s.AddImport(ctx, a0) 110 case "gopls.add_telemetry_counters": 111 var a0 AddTelemetryCountersArgs 112 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 113 return nil, err 114 } 115 return nil, s.AddTelemetryCounters(ctx, a0) 116 case "gopls.apply_fix": 117 var a0 ApplyFixArgs 118 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 119 return nil, err 120 } 121 return s.ApplyFix(ctx, a0) 122 case "gopls.change_signature": 123 var a0 ChangeSignatureArgs 124 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 125 return nil, err 126 } 127 return s.ChangeSignature(ctx, a0) 128 case "gopls.check_upgrades": 129 var a0 CheckUpgradesArgs 130 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 131 return nil, err 132 } 133 return nil, s.CheckUpgrades(ctx, a0) 134 case "gopls.diagnose_files": 135 var a0 DiagnoseFilesArgs 136 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 137 return nil, err 138 } 139 return nil, s.DiagnoseFiles(ctx, a0) 140 case "gopls.edit_go_directive": 141 var a0 EditGoDirectiveArgs 142 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 143 return nil, err 144 } 145 return nil, s.EditGoDirective(ctx, a0) 146 case "gopls.fetch_vulncheck_result": 147 var a0 URIArg 148 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 149 return nil, err 150 } 151 return s.FetchVulncheckResult(ctx, a0) 152 case "gopls.gc_details": 153 var a0 protocol.DocumentURI 154 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 155 return nil, err 156 } 157 return nil, s.GCDetails(ctx, a0) 158 case "gopls.generate": 159 var a0 GenerateArgs 160 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 161 return nil, err 162 } 163 return nil, s.Generate(ctx, a0) 164 case "gopls.go_get_package": 165 var a0 GoGetPackageArgs 166 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 167 return nil, err 168 } 169 return nil, s.GoGetPackage(ctx, a0) 170 case "gopls.list_imports": 171 var a0 URIArg 172 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 173 return nil, err 174 } 175 return s.ListImports(ctx, a0) 176 case "gopls.list_known_packages": 177 var a0 URIArg 178 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 179 return nil, err 180 } 181 return s.ListKnownPackages(ctx, a0) 182 case "gopls.maybe_prompt_for_telemetry": 183 return nil, s.MaybePromptForTelemetry(ctx) 184 case "gopls.mem_stats": 185 return s.MemStats(ctx) 186 case "gopls.regenerate_cgo": 187 var a0 URIArg 188 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 189 return nil, err 190 } 191 return nil, s.RegenerateCgo(ctx, a0) 192 case "gopls.remove_dependency": 193 var a0 RemoveDependencyArgs 194 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 195 return nil, err 196 } 197 return nil, s.RemoveDependency(ctx, a0) 198 case "gopls.reset_go_mod_diagnostics": 199 var a0 ResetGoModDiagnosticsArgs 200 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 201 return nil, err 202 } 203 return nil, s.ResetGoModDiagnostics(ctx, a0) 204 case "gopls.run_go_work_command": 205 var a0 RunGoWorkArgs 206 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 207 return nil, err 208 } 209 return nil, s.RunGoWorkCommand(ctx, a0) 210 case "gopls.run_govulncheck": 211 var a0 VulncheckArgs 212 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 213 return nil, err 214 } 215 return s.RunGovulncheck(ctx, a0) 216 case "gopls.run_tests": 217 var a0 RunTestsArgs 218 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 219 return nil, err 220 } 221 return nil, s.RunTests(ctx, a0) 222 case "gopls.start_debugging": 223 var a0 DebuggingArgs 224 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 225 return nil, err 226 } 227 return s.StartDebugging(ctx, a0) 228 case "gopls.start_profile": 229 var a0 StartProfileArgs 230 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 231 return nil, err 232 } 233 return s.StartProfile(ctx, a0) 234 case "gopls.stop_profile": 235 var a0 StopProfileArgs 236 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 237 return nil, err 238 } 239 return s.StopProfile(ctx, a0) 240 case "gopls.test": 241 var a0 protocol.DocumentURI 242 var a1 []string 243 var a2 []string 244 if err := UnmarshalArgs(params.Arguments, &a0, &a1, &a2); err != nil { 245 return nil, err 246 } 247 return nil, s.Test(ctx, a0, a1, a2) 248 case "gopls.tidy": 249 var a0 URIArgs 250 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 251 return nil, err 252 } 253 return nil, s.Tidy(ctx, a0) 254 case "gopls.toggle_gc_details": 255 var a0 URIArg 256 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 257 return nil, err 258 } 259 return nil, s.ToggleGCDetails(ctx, a0) 260 case "gopls.update_go_sum": 261 var a0 URIArgs 262 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 263 return nil, err 264 } 265 return nil, s.UpdateGoSum(ctx, a0) 266 case "gopls.upgrade_dependency": 267 var a0 DependencyArgs 268 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 269 return nil, err 270 } 271 return nil, s.UpgradeDependency(ctx, a0) 272 case "gopls.vendor": 273 var a0 URIArg 274 if err := UnmarshalArgs(params.Arguments, &a0); err != nil { 275 return nil, err 276 } 277 return nil, s.Vendor(ctx, a0) 278 case "gopls.views": 279 return s.Views(ctx) 280 case "gopls.workspace_stats": 281 return s.WorkspaceStats(ctx) 282 } 283 return nil, fmt.Errorf("unsupported command %q", params.Command) 284 } 285 286 func NewAddDependencyCommand(title string, a0 DependencyArgs) (protocol.Command, error) { 287 args, err := MarshalArgs(a0) 288 if err != nil { 289 return protocol.Command{}, err 290 } 291 return protocol.Command{ 292 Title: title, 293 Command: "gopls.add_dependency", 294 Arguments: args, 295 }, nil 296 } 297 298 func NewAddImportCommand(title string, a0 AddImportArgs) (protocol.Command, error) { 299 args, err := MarshalArgs(a0) 300 if err != nil { 301 return protocol.Command{}, err 302 } 303 return protocol.Command{ 304 Title: title, 305 Command: "gopls.add_import", 306 Arguments: args, 307 }, nil 308 } 309 310 func NewAddTelemetryCountersCommand(title string, a0 AddTelemetryCountersArgs) (protocol.Command, error) { 311 args, err := MarshalArgs(a0) 312 if err != nil { 313 return protocol.Command{}, err 314 } 315 return protocol.Command{ 316 Title: title, 317 Command: "gopls.add_telemetry_counters", 318 Arguments: args, 319 }, nil 320 } 321 322 func NewApplyFixCommand(title string, a0 ApplyFixArgs) (protocol.Command, error) { 323 args, err := MarshalArgs(a0) 324 if err != nil { 325 return protocol.Command{}, err 326 } 327 return protocol.Command{ 328 Title: title, 329 Command: "gopls.apply_fix", 330 Arguments: args, 331 }, nil 332 } 333 334 func NewChangeSignatureCommand(title string, a0 ChangeSignatureArgs) (protocol.Command, error) { 335 args, err := MarshalArgs(a0) 336 if err != nil { 337 return protocol.Command{}, err 338 } 339 return protocol.Command{ 340 Title: title, 341 Command: "gopls.change_signature", 342 Arguments: args, 343 }, nil 344 } 345 346 func NewCheckUpgradesCommand(title string, a0 CheckUpgradesArgs) (protocol.Command, error) { 347 args, err := MarshalArgs(a0) 348 if err != nil { 349 return protocol.Command{}, err 350 } 351 return protocol.Command{ 352 Title: title, 353 Command: "gopls.check_upgrades", 354 Arguments: args, 355 }, nil 356 } 357 358 func NewDiagnoseFilesCommand(title string, a0 DiagnoseFilesArgs) (protocol.Command, error) { 359 args, err := MarshalArgs(a0) 360 if err != nil { 361 return protocol.Command{}, err 362 } 363 return protocol.Command{ 364 Title: title, 365 Command: "gopls.diagnose_files", 366 Arguments: args, 367 }, nil 368 } 369 370 func NewEditGoDirectiveCommand(title string, a0 EditGoDirectiveArgs) (protocol.Command, error) { 371 args, err := MarshalArgs(a0) 372 if err != nil { 373 return protocol.Command{}, err 374 } 375 return protocol.Command{ 376 Title: title, 377 Command: "gopls.edit_go_directive", 378 Arguments: args, 379 }, nil 380 } 381 382 func NewFetchVulncheckResultCommand(title string, a0 URIArg) (protocol.Command, error) { 383 args, err := MarshalArgs(a0) 384 if err != nil { 385 return protocol.Command{}, err 386 } 387 return protocol.Command{ 388 Title: title, 389 Command: "gopls.fetch_vulncheck_result", 390 Arguments: args, 391 }, nil 392 } 393 394 func NewGCDetailsCommand(title string, a0 protocol.DocumentURI) (protocol.Command, error) { 395 args, err := MarshalArgs(a0) 396 if err != nil { 397 return protocol.Command{}, err 398 } 399 return protocol.Command{ 400 Title: title, 401 Command: "gopls.gc_details", 402 Arguments: args, 403 }, nil 404 } 405 406 func NewGenerateCommand(title string, a0 GenerateArgs) (protocol.Command, error) { 407 args, err := MarshalArgs(a0) 408 if err != nil { 409 return protocol.Command{}, err 410 } 411 return protocol.Command{ 412 Title: title, 413 Command: "gopls.generate", 414 Arguments: args, 415 }, nil 416 } 417 418 func NewGoGetPackageCommand(title string, a0 GoGetPackageArgs) (protocol.Command, error) { 419 args, err := MarshalArgs(a0) 420 if err != nil { 421 return protocol.Command{}, err 422 } 423 return protocol.Command{ 424 Title: title, 425 Command: "gopls.go_get_package", 426 Arguments: args, 427 }, nil 428 } 429 430 func NewListImportsCommand(title string, a0 URIArg) (protocol.Command, error) { 431 args, err := MarshalArgs(a0) 432 if err != nil { 433 return protocol.Command{}, err 434 } 435 return protocol.Command{ 436 Title: title, 437 Command: "gopls.list_imports", 438 Arguments: args, 439 }, nil 440 } 441 442 func NewListKnownPackagesCommand(title string, a0 URIArg) (protocol.Command, error) { 443 args, err := MarshalArgs(a0) 444 if err != nil { 445 return protocol.Command{}, err 446 } 447 return protocol.Command{ 448 Title: title, 449 Command: "gopls.list_known_packages", 450 Arguments: args, 451 }, nil 452 } 453 454 func NewMaybePromptForTelemetryCommand(title string) (protocol.Command, error) { 455 args, err := MarshalArgs() 456 if err != nil { 457 return protocol.Command{}, err 458 } 459 return protocol.Command{ 460 Title: title, 461 Command: "gopls.maybe_prompt_for_telemetry", 462 Arguments: args, 463 }, nil 464 } 465 466 func NewMemStatsCommand(title string) (protocol.Command, error) { 467 args, err := MarshalArgs() 468 if err != nil { 469 return protocol.Command{}, err 470 } 471 return protocol.Command{ 472 Title: title, 473 Command: "gopls.mem_stats", 474 Arguments: args, 475 }, nil 476 } 477 478 func NewRegenerateCgoCommand(title string, a0 URIArg) (protocol.Command, error) { 479 args, err := MarshalArgs(a0) 480 if err != nil { 481 return protocol.Command{}, err 482 } 483 return protocol.Command{ 484 Title: title, 485 Command: "gopls.regenerate_cgo", 486 Arguments: args, 487 }, nil 488 } 489 490 func NewRemoveDependencyCommand(title string, a0 RemoveDependencyArgs) (protocol.Command, error) { 491 args, err := MarshalArgs(a0) 492 if err != nil { 493 return protocol.Command{}, err 494 } 495 return protocol.Command{ 496 Title: title, 497 Command: "gopls.remove_dependency", 498 Arguments: args, 499 }, nil 500 } 501 502 func NewResetGoModDiagnosticsCommand(title string, a0 ResetGoModDiagnosticsArgs) (protocol.Command, error) { 503 args, err := MarshalArgs(a0) 504 if err != nil { 505 return protocol.Command{}, err 506 } 507 return protocol.Command{ 508 Title: title, 509 Command: "gopls.reset_go_mod_diagnostics", 510 Arguments: args, 511 }, nil 512 } 513 514 func NewRunGoWorkCommandCommand(title string, a0 RunGoWorkArgs) (protocol.Command, error) { 515 args, err := MarshalArgs(a0) 516 if err != nil { 517 return protocol.Command{}, err 518 } 519 return protocol.Command{ 520 Title: title, 521 Command: "gopls.run_go_work_command", 522 Arguments: args, 523 }, nil 524 } 525 526 func NewRunGovulncheckCommand(title string, a0 VulncheckArgs) (protocol.Command, error) { 527 args, err := MarshalArgs(a0) 528 if err != nil { 529 return protocol.Command{}, err 530 } 531 return protocol.Command{ 532 Title: title, 533 Command: "gopls.run_govulncheck", 534 Arguments: args, 535 }, nil 536 } 537 538 func NewRunTestsCommand(title string, a0 RunTestsArgs) (protocol.Command, error) { 539 args, err := MarshalArgs(a0) 540 if err != nil { 541 return protocol.Command{}, err 542 } 543 return protocol.Command{ 544 Title: title, 545 Command: "gopls.run_tests", 546 Arguments: args, 547 }, nil 548 } 549 550 func NewStartDebuggingCommand(title string, a0 DebuggingArgs) (protocol.Command, error) { 551 args, err := MarshalArgs(a0) 552 if err != nil { 553 return protocol.Command{}, err 554 } 555 return protocol.Command{ 556 Title: title, 557 Command: "gopls.start_debugging", 558 Arguments: args, 559 }, nil 560 } 561 562 func NewStartProfileCommand(title string, a0 StartProfileArgs) (protocol.Command, error) { 563 args, err := MarshalArgs(a0) 564 if err != nil { 565 return protocol.Command{}, err 566 } 567 return protocol.Command{ 568 Title: title, 569 Command: "gopls.start_profile", 570 Arguments: args, 571 }, nil 572 } 573 574 func NewStopProfileCommand(title string, a0 StopProfileArgs) (protocol.Command, error) { 575 args, err := MarshalArgs(a0) 576 if err != nil { 577 return protocol.Command{}, err 578 } 579 return protocol.Command{ 580 Title: title, 581 Command: "gopls.stop_profile", 582 Arguments: args, 583 }, nil 584 } 585 586 func NewTestCommand(title string, a0 protocol.DocumentURI, a1 []string, a2 []string) (protocol.Command, error) { 587 args, err := MarshalArgs(a0, a1, a2) 588 if err != nil { 589 return protocol.Command{}, err 590 } 591 return protocol.Command{ 592 Title: title, 593 Command: "gopls.test", 594 Arguments: args, 595 }, nil 596 } 597 598 func NewTidyCommand(title string, a0 URIArgs) (protocol.Command, error) { 599 args, err := MarshalArgs(a0) 600 if err != nil { 601 return protocol.Command{}, err 602 } 603 return protocol.Command{ 604 Title: title, 605 Command: "gopls.tidy", 606 Arguments: args, 607 }, nil 608 } 609 610 func NewToggleGCDetailsCommand(title string, a0 URIArg) (protocol.Command, error) { 611 args, err := MarshalArgs(a0) 612 if err != nil { 613 return protocol.Command{}, err 614 } 615 return protocol.Command{ 616 Title: title, 617 Command: "gopls.toggle_gc_details", 618 Arguments: args, 619 }, nil 620 } 621 622 func NewUpdateGoSumCommand(title string, a0 URIArgs) (protocol.Command, error) { 623 args, err := MarshalArgs(a0) 624 if err != nil { 625 return protocol.Command{}, err 626 } 627 return protocol.Command{ 628 Title: title, 629 Command: "gopls.update_go_sum", 630 Arguments: args, 631 }, nil 632 } 633 634 func NewUpgradeDependencyCommand(title string, a0 DependencyArgs) (protocol.Command, error) { 635 args, err := MarshalArgs(a0) 636 if err != nil { 637 return protocol.Command{}, err 638 } 639 return protocol.Command{ 640 Title: title, 641 Command: "gopls.upgrade_dependency", 642 Arguments: args, 643 }, nil 644 } 645 646 func NewVendorCommand(title string, a0 URIArg) (protocol.Command, error) { 647 args, err := MarshalArgs(a0) 648 if err != nil { 649 return protocol.Command{}, err 650 } 651 return protocol.Command{ 652 Title: title, 653 Command: "gopls.vendor", 654 Arguments: args, 655 }, nil 656 } 657 658 func NewViewsCommand(title string) (protocol.Command, error) { 659 args, err := MarshalArgs() 660 if err != nil { 661 return protocol.Command{}, err 662 } 663 return protocol.Command{ 664 Title: title, 665 Command: "gopls.views", 666 Arguments: args, 667 }, nil 668 } 669 670 func NewWorkspaceStatsCommand(title string) (protocol.Command, error) { 671 args, err := MarshalArgs() 672 if err != nil { 673 return protocol.Command{}, err 674 } 675 return protocol.Command{ 676 Title: title, 677 Command: "gopls.workspace_stats", 678 Arguments: args, 679 }, nil 680 }