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