зеркало из https://github.com/golang/tools.git
gopls/doc: delete commands.md
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 commit is contained in:
Родитель
2154cbf88d
Коммит
f6a239054f
|
@ -1,965 +0,0 @@
|
|||
# Gopls: Commands
|
||||
|
||||
The LSP's `workspace/executeCommand` RPC is an extension mechanism
|
||||
that allows clients to invoke ad hoc commands offered by servers.
|
||||
This document describes the commands supported by `gopls`.
|
||||
|
||||
Most commands provide the implementations of features advertised
|
||||
through documented LSP mechanisms such as
|
||||
[Code Lenses](settings.md#code-lenses) and
|
||||
[Code Actions](features/transformation.md#code-actions).
|
||||
|
||||
They are not intended to be invoked directly by clients,
|
||||
and typically editors do not make them directly accessible.
|
||||
|
||||
We document them for completeness, but these interfaces
|
||||
are not stable and may change without notice.
|
||||
TODO(rfindley): unpublish and remove this page.
|
||||
|
||||
<!-- BEGIN Commands: DO NOT MANUALLY EDIT THIS SECTION -->
|
||||
<a id='gopls.add_dependency'></a>
|
||||
## `gopls.add_dependency`: **Add a dependency**
|
||||
|
||||
Adds a dependency to the go.mod file for a module.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// The go.mod file URI.
|
||||
"URI": string,
|
||||
// Additional args to pass to the go command.
|
||||
"GoCmdArgs": []string,
|
||||
// Whether to add a require directive.
|
||||
"AddRequire": bool,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.add_import'></a>
|
||||
## `gopls.add_import`: **Add an import**
|
||||
|
||||
Ask the server to add an import path to a given Go file. The method will
|
||||
call applyEdit on the client so that clients don't have to apply the edit
|
||||
themselves.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// ImportPath is the target import path that should
|
||||
// be added to the URI file
|
||||
"ImportPath": string,
|
||||
// URI is the file that the ImportPath should be
|
||||
// added to
|
||||
"URI": string,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.add_telemetry_counters'></a>
|
||||
## `gopls.add_telemetry_counters`: **Update the given telemetry counters**
|
||||
|
||||
Gopls will prepend "fwd/" to all the counters updated using this command
|
||||
to avoid conflicts with other counters gopls collects.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// Names and Values must have the same length.
|
||||
"Names": []string,
|
||||
"Values": []int64,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.apply_fix'></a>
|
||||
## `gopls.apply_fix`: **Apply a fix**
|
||||
|
||||
Applies a fix to a region of source code.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// The name of the fix to apply.
|
||||
//
|
||||
// For fixes suggested by analyzers, this is a string constant
|
||||
// advertised by the analyzer that matches the Category of
|
||||
// the analysis.Diagnostic with a SuggestedFix containing no edits.
|
||||
//
|
||||
// For fixes suggested by code actions, this is a string agreed
|
||||
// upon by the code action and golang.ApplyFix.
|
||||
"Fix": string,
|
||||
// The file URI for the document to fix.
|
||||
"URI": string,
|
||||
// The document range to scan for fixes.
|
||||
"Range": {
|
||||
"start": {
|
||||
"line": uint32,
|
||||
"character": uint32,
|
||||
},
|
||||
"end": {
|
||||
"line": uint32,
|
||||
"character": uint32,
|
||||
},
|
||||
},
|
||||
// Whether to resolve and return the edits.
|
||||
"ResolveEdits": bool,
|
||||
}
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
{
|
||||
// Holds changes to existing resources.
|
||||
"changes": map[golang.org/x/tools/gopls/internal/protocol.DocumentURI][]golang.org/x/tools/gopls/internal/protocol.TextEdit,
|
||||
// Depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes
|
||||
// are either an array of `TextDocumentEdit`s to express changes to n different text documents
|
||||
// where each text document edit addresses a specific version of a text document. Or it can contain
|
||||
// above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations.
|
||||
//
|
||||
// Whether a client supports versioned document edits is expressed via
|
||||
// `workspace.workspaceEdit.documentChanges` client capability.
|
||||
//
|
||||
// If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then
|
||||
// only plain `TextEdit`s using the `changes` property are supported.
|
||||
"documentChanges": []{
|
||||
"TextDocumentEdit": {
|
||||
"textDocument": { ... },
|
||||
"edits": { ... },
|
||||
},
|
||||
"CreateFile": {
|
||||
"kind": string,
|
||||
"uri": string,
|
||||
"options": { ... },
|
||||
"ResourceOperation": { ... },
|
||||
},
|
||||
"RenameFile": {
|
||||
"kind": string,
|
||||
"oldUri": string,
|
||||
"newUri": string,
|
||||
"options": { ... },
|
||||
"ResourceOperation": { ... },
|
||||
},
|
||||
"DeleteFile": {
|
||||
"kind": string,
|
||||
"uri": string,
|
||||
"options": { ... },
|
||||
"ResourceOperation": { ... },
|
||||
},
|
||||
},
|
||||
// A map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and
|
||||
// delete file / folder operations.
|
||||
//
|
||||
// Whether clients honor this property depends on the client capability `workspace.changeAnnotationSupport`.
|
||||
//
|
||||
// @since 3.16.0
|
||||
"changeAnnotations": map[string]golang.org/x/tools/gopls/internal/protocol.ChangeAnnotation,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.assembly'></a>
|
||||
## `gopls.assembly`: **Browse assembly listing of current function in a browser.**
|
||||
|
||||
This command opens a web-based disassembly listing of the
|
||||
specified function symbol (plus any nested lambdas and defers).
|
||||
The machine architecture is determined by the view.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
string,
|
||||
string,
|
||||
string
|
||||
```
|
||||
|
||||
<a id='gopls.change_signature'></a>
|
||||
## `gopls.change_signature`: **Perform a "change signature" refactoring**
|
||||
|
||||
This command is experimental, currently only supporting parameter removal.
|
||||
Its signature will certainly change in the future (pun intended).
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
"RemoveParameter": {
|
||||
"uri": string,
|
||||
"range": {
|
||||
"start": { ... },
|
||||
"end": { ... },
|
||||
},
|
||||
},
|
||||
// Whether to resolve and return the edits.
|
||||
"ResolveEdits": bool,
|
||||
}
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
{
|
||||
// Holds changes to existing resources.
|
||||
"changes": map[golang.org/x/tools/gopls/internal/protocol.DocumentURI][]golang.org/x/tools/gopls/internal/protocol.TextEdit,
|
||||
// Depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes
|
||||
// are either an array of `TextDocumentEdit`s to express changes to n different text documents
|
||||
// where each text document edit addresses a specific version of a text document. Or it can contain
|
||||
// above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations.
|
||||
//
|
||||
// Whether a client supports versioned document edits is expressed via
|
||||
// `workspace.workspaceEdit.documentChanges` client capability.
|
||||
//
|
||||
// If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then
|
||||
// only plain `TextEdit`s using the `changes` property are supported.
|
||||
"documentChanges": []{
|
||||
"TextDocumentEdit": {
|
||||
"textDocument": { ... },
|
||||
"edits": { ... },
|
||||
},
|
||||
"CreateFile": {
|
||||
"kind": string,
|
||||
"uri": string,
|
||||
"options": { ... },
|
||||
"ResourceOperation": { ... },
|
||||
},
|
||||
"RenameFile": {
|
||||
"kind": string,
|
||||
"oldUri": string,
|
||||
"newUri": string,
|
||||
"options": { ... },
|
||||
"ResourceOperation": { ... },
|
||||
},
|
||||
"DeleteFile": {
|
||||
"kind": string,
|
||||
"uri": string,
|
||||
"options": { ... },
|
||||
"ResourceOperation": { ... },
|
||||
},
|
||||
},
|
||||
// A map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and
|
||||
// delete file / folder operations.
|
||||
//
|
||||
// Whether clients honor this property depends on the client capability `workspace.changeAnnotationSupport`.
|
||||
//
|
||||
// @since 3.16.0
|
||||
"changeAnnotations": map[string]golang.org/x/tools/gopls/internal/protocol.ChangeAnnotation,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.check_upgrades'></a>
|
||||
## `gopls.check_upgrades`: **Check for upgrades**
|
||||
|
||||
Checks for module upgrades.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// The go.mod file URI.
|
||||
"URI": string,
|
||||
// The modules to check.
|
||||
"Modules": []string,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.client_open_url'></a>
|
||||
## `gopls.client_open_url`: **Request that the client open a URL in a browser.**
|
||||
|
||||
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
string
|
||||
```
|
||||
|
||||
<a id='gopls.diagnose_files'></a>
|
||||
## `gopls.diagnose_files`: **Cause server to publish diagnostics for the specified files.**
|
||||
|
||||
This command is needed by the 'gopls {check,fix}' CLI subcommands.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
"Files": []string,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.doc'></a>
|
||||
## `gopls.doc`: **Browse package documentation.**
|
||||
|
||||
Opens the Go package documentation page for the current
|
||||
package in a browser.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
"uri": string,
|
||||
"range": {
|
||||
"start": {
|
||||
"line": uint32,
|
||||
"character": uint32,
|
||||
},
|
||||
"end": {
|
||||
"line": uint32,
|
||||
"character": uint32,
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.edit_go_directive'></a>
|
||||
## `gopls.edit_go_directive`: **Run go mod edit -go=version**
|
||||
|
||||
Runs `go mod edit -go=version` for a module.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// Any document URI within the relevant module.
|
||||
"URI": string,
|
||||
// The version to pass to `go mod edit -go`.
|
||||
"Version": string,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.extract_to_new_file'></a>
|
||||
## `gopls.extract_to_new_file`: **Move selected declarations to a new file**
|
||||
|
||||
Used by the code action of the same name.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
"uri": string,
|
||||
"range": {
|
||||
"start": {
|
||||
"line": uint32,
|
||||
"character": uint32,
|
||||
},
|
||||
"end": {
|
||||
"line": uint32,
|
||||
"character": uint32,
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.fetch_vulncheck_result'></a>
|
||||
## `gopls.fetch_vulncheck_result`: **Get known vulncheck result**
|
||||
|
||||
Fetch the result of latest vulnerability check (`govulncheck`).
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// The file URI.
|
||||
"URI": string,
|
||||
}
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
map[golang.org/x/tools/gopls/internal/protocol.DocumentURI]*golang.org/x/tools/gopls/internal/vulncheck.Result
|
||||
```
|
||||
|
||||
<a id='gopls.free_symbols'></a>
|
||||
## `gopls.free_symbols`: **Browse free symbols referenced by the selection in a browser.**
|
||||
|
||||
This command is a query over a selected range of Go source
|
||||
code. It reports the set of "free" symbols of the
|
||||
selection: the set of symbols that are referenced within
|
||||
the selection but are declared outside of it. This
|
||||
information is useful for understanding at a glance what a
|
||||
block of code depends on, perhaps as a precursor to
|
||||
extracting it into a separate function.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
string,
|
||||
{
|
||||
"uri": string,
|
||||
"range": {
|
||||
"start": {
|
||||
"line": uint32,
|
||||
"character": uint32,
|
||||
},
|
||||
"end": {
|
||||
"line": uint32,
|
||||
"character": uint32,
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.gc_details'></a>
|
||||
## `gopls.gc_details`: **Toggle gc_details**
|
||||
|
||||
Toggle the calculation of gc annotations.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
string
|
||||
```
|
||||
|
||||
<a id='gopls.generate'></a>
|
||||
## `gopls.generate`: **Run go generate**
|
||||
|
||||
Runs `go generate` for a given directory.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// URI for the directory to generate.
|
||||
"Dir": string,
|
||||
// Whether to generate recursively (go generate ./...)
|
||||
"Recursive": bool,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.go_get_package'></a>
|
||||
## `gopls.go_get_package`: **'go get' a package**
|
||||
|
||||
Runs `go get` to fetch a package.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// Any document URI within the relevant module.
|
||||
"URI": string,
|
||||
// The package to go get.
|
||||
"Pkg": string,
|
||||
"AddRequire": bool,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.list_imports'></a>
|
||||
## `gopls.list_imports`: **List imports of a file and its package**
|
||||
|
||||
Retrieve a list of imports in the given Go file, and the package it
|
||||
belongs to.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// The file URI.
|
||||
"URI": string,
|
||||
}
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
{
|
||||
// Imports is a list of imports in the requested file.
|
||||
"Imports": []{
|
||||
"Path": string,
|
||||
"Name": string,
|
||||
},
|
||||
// PackageImports is a list of all imports in the requested file's package.
|
||||
"PackageImports": []{
|
||||
"Path": string,
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.list_known_packages'></a>
|
||||
## `gopls.list_known_packages`: **List known packages**
|
||||
|
||||
Retrieve a list of packages that are importable from the given URI.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// The file URI.
|
||||
"URI": string,
|
||||
}
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
{
|
||||
// Packages is a list of packages relative
|
||||
// to the URIArg passed by the command request.
|
||||
// In other words, it omits paths that are already
|
||||
// imported or cannot be imported due to compiler
|
||||
// restrictions.
|
||||
"Packages": []string,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.maybe_prompt_for_telemetry'></a>
|
||||
## `gopls.maybe_prompt_for_telemetry`: **Prompt user to enable telemetry**
|
||||
|
||||
Checks for the right conditions, and then prompts the user
|
||||
to ask if they want to enable Go telemetry uploading. If
|
||||
the user responds 'Yes', the telemetry mode is set to "on".
|
||||
|
||||
<a id='gopls.mem_stats'></a>
|
||||
## `gopls.mem_stats`: **Fetch memory statistics**
|
||||
|
||||
Call runtime.GC multiple times and return memory statistics as reported by
|
||||
runtime.MemStats.
|
||||
|
||||
This command is used for benchmarking, and may change in the future.
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
{
|
||||
"HeapAlloc": uint64,
|
||||
"HeapInUse": uint64,
|
||||
"TotalAlloc": uint64,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.modules'></a>
|
||||
## `gopls.modules`: **Return information about modules within a directory**
|
||||
|
||||
This command returns an empty result if there is no module,
|
||||
or if module mode is disabled.
|
||||
The result does not includes the modules that are not
|
||||
associated with any Views on the server yet.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// Dir is the directory in which to search for go.mod files.
|
||||
"Dir": string,
|
||||
// MaxDepth is the directory walk limit.
|
||||
// A value of 0 means inspect only Dir.
|
||||
// 1 means inspect its child directories too, and so on.
|
||||
// A negative value removes the limit.
|
||||
"MaxDepth": int,
|
||||
}
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
{
|
||||
"Modules": []{
|
||||
"Path": string,
|
||||
"Version": string,
|
||||
"GoMod": string,
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.packages'></a>
|
||||
## `gopls.packages`: **Return information about packages**
|
||||
|
||||
This command returns an empty result if the specified files
|
||||
or directories are not associated with any Views on the
|
||||
server yet.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// Files is a list of files and directories whose associated
|
||||
// packages should be described by the result.
|
||||
//
|
||||
// In some cases, a file may belong to more than one package;
|
||||
// the result may describe any of them.
|
||||
"Files": []string,
|
||||
// Enumerate all packages under the directry loadable with
|
||||
// the ... pattern.
|
||||
// The search does not cross the module boundaries and
|
||||
// does not return packages that are not yet loaded.
|
||||
// (e.g. those excluded by the gopls directory filter setting,
|
||||
// or the go.work configuration)
|
||||
"Recursive": bool,
|
||||
// Mode controls the types of information returned for each package.
|
||||
"Mode": uint64,
|
||||
}
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
{
|
||||
// Packages is an unordered list of package metadata.
|
||||
"Packages": []{
|
||||
"Path": string,
|
||||
"ModulePath": string,
|
||||
"TestFiles": []{
|
||||
"URI": string,
|
||||
"Tests": { ... },
|
||||
},
|
||||
},
|
||||
// Modules maps module path to module metadata for
|
||||
// all the modules of the returned Packages.
|
||||
"Module": map[string]golang.org/x/tools/gopls/internal/protocol/command.Module,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.regenerate_cgo'></a>
|
||||
## `gopls.regenerate_cgo`: **Regenerate cgo**
|
||||
|
||||
Regenerates cgo definitions.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// The file URI.
|
||||
"URI": string,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.remove_dependency'></a>
|
||||
## `gopls.remove_dependency`: **Remove a dependency**
|
||||
|
||||
Removes a dependency from the go.mod file of a module.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// The go.mod file URI.
|
||||
"URI": string,
|
||||
// The module path to remove.
|
||||
"ModulePath": string,
|
||||
// If the module is tidied apart from the one unused diagnostic, we can
|
||||
// run `go get module@none`, and then run `go mod tidy`. Otherwise, we
|
||||
// must make textual edits.
|
||||
"OnlyDiagnostic": bool,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.reset_go_mod_diagnostics'></a>
|
||||
## `gopls.reset_go_mod_diagnostics`: **Reset go.mod diagnostics**
|
||||
|
||||
Reset diagnostics in the go.mod file of a module.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
"URIArg": {
|
||||
"URI": string,
|
||||
},
|
||||
// Optional: source of the diagnostics to reset.
|
||||
// If not set, all resettable go.mod diagnostics will be cleared.
|
||||
"DiagnosticSource": string,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.run_go_work_command'></a>
|
||||
## `gopls.run_go_work_command`: **Run `go work [args...]`, and apply the resulting go.work**
|
||||
|
||||
edits to the current go.work file
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
"ViewID": string,
|
||||
"InitFirst": bool,
|
||||
"Args": []string,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.run_govulncheck'></a>
|
||||
## `gopls.run_govulncheck`: **Run vulncheck**
|
||||
|
||||
Run vulnerability check (`govulncheck`).
|
||||
|
||||
This command is asynchronous; clients must wait for the 'end' progress notification.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// Any document in the directory from which govulncheck will run.
|
||||
"URI": string,
|
||||
// Package pattern. E.g. "", ".", "./...".
|
||||
"Pattern": string,
|
||||
}
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
{
|
||||
// Token holds the progress token for LSP workDone reporting of the vulncheck
|
||||
// invocation.
|
||||
"Token": interface{},
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.run_tests'></a>
|
||||
## `gopls.run_tests`: **Run test(s)**
|
||||
|
||||
Runs `go test` for a specific set of test or benchmark functions.
|
||||
|
||||
This command is asynchronous; clients must wait for the 'end' progress notification.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// The test file containing the tests to run.
|
||||
"URI": string,
|
||||
// Specific test names to run, e.g. TestFoo.
|
||||
"Tests": []string,
|
||||
// Specific benchmarks to run, e.g. BenchmarkFoo.
|
||||
"Benchmarks": []string,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.scan_imports'></a>
|
||||
## `gopls.scan_imports`: **force a sychronous scan of the imports cache.**
|
||||
|
||||
This command is intended for use by gopls tests only.
|
||||
|
||||
<a id='gopls.start_debugging'></a>
|
||||
## `gopls.start_debugging`: **Start the gopls debug server**
|
||||
|
||||
Start the gopls debug server if it isn't running, and return the debug
|
||||
address.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// Optional: the address (including port) for the debug server to listen on.
|
||||
// If not provided, the debug server will bind to "localhost:0", and the
|
||||
// full debug URL will be contained in the result.
|
||||
//
|
||||
// If there is more than one gopls instance along the serving path (i.e. you
|
||||
// are using a daemon), each gopls instance will attempt to start debugging.
|
||||
// If Addr specifies a port, only the daemon will be able to bind to that
|
||||
// port, and each intermediate gopls instance will fail to start debugging.
|
||||
// For this reason it is recommended not to specify a port (or equivalently,
|
||||
// to specify ":0").
|
||||
//
|
||||
// If the server was already debugging this field has no effect, and the
|
||||
// result will contain the previously configured debug URL(s).
|
||||
"Addr": string,
|
||||
}
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
{
|
||||
// The URLs to use to access the debug servers, for all gopls instances in
|
||||
// the serving path. For the common case of a single gopls instance (i.e. no
|
||||
// daemon), this will be exactly one address.
|
||||
//
|
||||
// In the case of one or more gopls instances forwarding the LSP to a daemon,
|
||||
// URLs will contain debug addresses for each server in the serving path, in
|
||||
// serving order. The daemon debug address will be the last entry in the
|
||||
// slice. If any intermediate gopls instance fails to start debugging, no
|
||||
// error will be returned but the debug URL for that server in the URLs slice
|
||||
// will be empty.
|
||||
"URLs": []string,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.start_profile'></a>
|
||||
## `gopls.start_profile`: **Start capturing a profile of gopls' execution**
|
||||
|
||||
Start a new pprof profile. Before using the resulting file, profiling must
|
||||
be stopped with a corresponding call to StopProfile.
|
||||
|
||||
This command is intended for internal use only, by the gopls benchmark
|
||||
runner.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
struct{}
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
struct{}
|
||||
```
|
||||
|
||||
<a id='gopls.stop_profile'></a>
|
||||
## `gopls.stop_profile`: **Stop an ongoing profile**
|
||||
|
||||
This command is intended for internal use only, by the gopls benchmark
|
||||
runner.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
struct{}
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
{
|
||||
// File is the profile file name.
|
||||
"File": string,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.test'></a>
|
||||
## `gopls.test`: **Run test(s) (legacy)**
|
||||
|
||||
Runs `go test` for a specific set of test or benchmark functions.
|
||||
|
||||
This command is asynchronous; wait for the 'end' progress notification.
|
||||
|
||||
This command is an alias for RunTests; the only difference
|
||||
is the form of the parameters.
|
||||
|
||||
TODO(adonovan): eliminate it.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
string,
|
||||
[]string,
|
||||
[]string
|
||||
```
|
||||
|
||||
<a id='gopls.tidy'></a>
|
||||
## `gopls.tidy`: **Run go mod tidy**
|
||||
|
||||
Runs `go mod tidy` for a module.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// The file URIs.
|
||||
"URIs": []string,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.toggle_gc_details'></a>
|
||||
## `gopls.toggle_gc_details`: **Toggle gc_details**
|
||||
|
||||
Toggle the calculation of gc annotations.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// The file URI.
|
||||
"URI": string,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.update_go_sum'></a>
|
||||
## `gopls.update_go_sum`: **Update go.sum**
|
||||
|
||||
Updates the go.sum file for a module.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// The file URIs.
|
||||
"URIs": []string,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.upgrade_dependency'></a>
|
||||
## `gopls.upgrade_dependency`: **Upgrade a dependency**
|
||||
|
||||
Upgrades a dependency in the go.mod file for a module.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// The go.mod file URI.
|
||||
"URI": string,
|
||||
// Additional args to pass to the go command.
|
||||
"GoCmdArgs": []string,
|
||||
// Whether to add a require directive.
|
||||
"AddRequire": bool,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.vendor'></a>
|
||||
## `gopls.vendor`: **Run go mod vendor**
|
||||
|
||||
Runs `go mod vendor` for a module.
|
||||
|
||||
Args:
|
||||
|
||||
```
|
||||
{
|
||||
// The file URI.
|
||||
"URI": string,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.views'></a>
|
||||
## `gopls.views`: **List current Views on the server.**
|
||||
|
||||
This command is intended for use by gopls tests only.
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
[]{
|
||||
"ID": string,
|
||||
"Type": string,
|
||||
"Root": string,
|
||||
"Folder": string,
|
||||
"EnvOverlay": []string,
|
||||
}
|
||||
```
|
||||
|
||||
<a id='gopls.workspace_stats'></a>
|
||||
## `gopls.workspace_stats`: **Fetch workspace statistics**
|
||||
|
||||
Query statistics about workspace builds, modules, packages, and files.
|
||||
|
||||
This command is intended for internal use only, by the gopls stats
|
||||
command.
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
{
|
||||
"Files": {
|
||||
"Total": int,
|
||||
"Largest": int,
|
||||
"Errs": int,
|
||||
},
|
||||
"Views": []{
|
||||
"GoCommandVersion": string,
|
||||
"AllPackages": {
|
||||
"Packages": int,
|
||||
"LargestPackage": int,
|
||||
"CompiledGoFiles": int,
|
||||
"Modules": int,
|
||||
},
|
||||
"WorkspacePackages": {
|
||||
"Packages": int,
|
||||
"LargestPackage": int,
|
||||
"CompiledGoFiles": int,
|
||||
"Modules": int,
|
||||
},
|
||||
"Diagnostics": int,
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
<!-- END Commands: DO NOT MANUALLY EDIT THIS SECTION -->
|
|
@ -58,7 +58,6 @@ when making significant changes to existing features or when adding new ones.
|
|||
- [Template files](templates.md): files parsed by `text/template` and `html/template`
|
||||
- [go.mod and go.work files](modfiles.md): Go module and workspace manifests
|
||||
- [Command-line interface](../command-line.md): CLI for debugging and scripting (unstable)
|
||||
- [Non-standard commands](../commands.md): gopls-specific RPC protocol extensions (unstable)
|
||||
|
||||
You can find this page from within your editor by executing the
|
||||
`gopls.doc.features` [code action](transformation.md#code-actions),
|
||||
|
|
|
@ -6,12 +6,15 @@ formatting, simplifications), code repair (fixes), and editing support
|
|||
(filling in struct literals and switch statements).
|
||||
|
||||
Code transformations are not a single category in the LSP:
|
||||
- a few, such as Formatting and Rename, are primary operations in the
|
||||
protocol;
|
||||
- some are [commands](../commands.md) exposed through [Code
|
||||
Lenses](../codelenses.md) (though none of these are transformations of Go syntax);
|
||||
- A few, such as Formatting and Rename, are primary operations in the
|
||||
protocol.
|
||||
- Some transformations are exposed through [Code Lenses](../codelenses.md),
|
||||
which return _commands_, arbitrary server
|
||||
operations invoked for their side effects through a
|
||||
[`workspace/executeCommand`](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_executeCommand) request;
|
||||
however, no current code lenses are transformations of Go syntax.
|
||||
<!-- Generate, RegenerateCgo (Go); Tidy, UpgradeDependency, Vendor (go.mod) -->
|
||||
- most are defined as *code actions*.
|
||||
- Most transformations are defined as *code actions*.
|
||||
|
||||
## Code Actions
|
||||
|
||||
|
@ -27,9 +30,8 @@ A `codeAction` request delivers the menu, so to speak, but it does
|
|||
not order the meal. Once the user chooses an action, one of two things happens.
|
||||
In trivial cases, the action itself contains an edit that the
|
||||
client can directly apply to the file.
|
||||
But in most cases, the action contains a [command](../commands.md)
|
||||
to be sent back to the server for its side effects,
|
||||
just as with the command associated with a Code Lens.
|
||||
But in most cases the action contains a command,
|
||||
similar to the command associated with a code lens.
|
||||
This allows the work of computing the patch to be done lazily, only
|
||||
when actually needed. (Most aren't.)
|
||||
The server may then compute the edit and send the client a
|
||||
|
|
|
@ -49,10 +49,10 @@ your source code has been modified but not saved.
|
|||
like your editor to raise its window when handling this event.)
|
||||
|
||||
<a name='doc'></a>
|
||||
## View package documentation
|
||||
## Browse package documentation
|
||||
|
||||
In any Go source file, a code action request returns a command to
|
||||
"View package documentation". This command opens a browser window
|
||||
"Browse package documentation". This command opens a browser window
|
||||
showing the documentation for the current Go package, presented using
|
||||
a similar design to https://pkg.go.dev.
|
||||
|
||||
|
@ -61,7 +61,7 @@ internal ones that may be unpublished externally. Reloading the page
|
|||
updates the documentation to reflect your changes. It is not necessary
|
||||
to save modified Go source files.
|
||||
|
||||
<img title="View package documentation" src="../assets/browse-pkg-doc.png" width='80%'>
|
||||
<img title="Browse package documentation" src="../assets/browse-pkg-doc.png" width='80%'>
|
||||
|
||||
Clicking on the link for a package-level symbol or method, which in
|
||||
`pkg.go.dev` would ordinarily take you to a source-code viewer such as
|
||||
|
@ -69,13 +69,13 @@ GitHub or Google Code Search, causes your editor to navigate to the
|
|||
relevant source file and line.
|
||||
|
||||
Client support:
|
||||
- **VS Code**: Use the "Source Action... > View package documentation" menu.
|
||||
- **VS Code**: Use the "Source Action... > Browse documentation for package P" menu.
|
||||
- **Emacs + eglot**: Use `M-x go-browse-doc` in [go-mode](https://github.com/dominikh/go-mode.el).
|
||||
- **Vim + coc.nvim**: ??
|
||||
|
||||
|
||||
<a name='freesymbols'></a>
|
||||
## View free symbols
|
||||
## Browse free symbols
|
||||
|
||||
When studying code, either to understand it or to evaluate a different
|
||||
organization or factoring, it is common to need to know what the
|
||||
|
@ -84,14 +84,14 @@ considering extracting it into its own function and want to know what
|
|||
parameters it would take, or just to understand how one piece of a long
|
||||
function relates to the preceding pieces.
|
||||
|
||||
If you select a chunk of code, and apply the "[View free
|
||||
symbols](../commands.md#gopls.free_symbols)" command, your editor will
|
||||
If you select a chunk of code, and invoke the "Browse free symbols"
|
||||
[code action](transformation.md#code-actions), your editor will
|
||||
open a browser displaying a report on the free symbols of the
|
||||
selection. A symbol is "free" if it is referenced from within the
|
||||
selection but defined outside of it. In essence, these are the inputs
|
||||
to the selected chunk.
|
||||
|
||||
<img title="View free symbols" src="../assets/browse-free-symbols.png" width='80%'>
|
||||
<img title="Browse free symbols" src="../assets/browse-free-symbols.png" width='80%'>
|
||||
|
||||
The report classifies the symbols into imported, local, and
|
||||
package-level symbols. The imported symbols are grouped by package,
|
||||
|
@ -102,23 +102,22 @@ editor to navigate to its declaration.
|
|||
TODO: explain dotted paths.
|
||||
|
||||
Client support:
|
||||
- **VS Code**: Use the "Source Action... > View free symbols" menu.
|
||||
- **VS Code**: Use the "Source Action... > Browse free symbols" menu.
|
||||
- **Emacs + eglot**: Use `M-x go-browse-freesymbols` in [go-mode](https://github.com/dominikh/go-mode.el).
|
||||
- **Vim + coc.nvim**: ??
|
||||
|
||||
|
||||
<a name='assembly'></a>
|
||||
## View assembly
|
||||
## Browsse assembly
|
||||
|
||||
When you're optimizing the performance of your code or investigating
|
||||
an unexpected crash, it may sometimes be helpful to inspect the
|
||||
assembly code produced by the compiler for a given Go function.
|
||||
|
||||
If you position the cursor or selection within a function f, a code
|
||||
action will offer the "[View assembly for
|
||||
f](../commands.md#gopls.assembly)" command. This opens a web-based
|
||||
listing of the assembly for the function, plus any functions nested
|
||||
within it.
|
||||
If you position the cursor or selection within a function f,
|
||||
gopls offers the "Browse assembly for f" [code action](transformation.md#code-actions).
|
||||
This opens a web-based listing of the assembly for the function, plus
|
||||
any functions nested within it.
|
||||
|
||||
Each time you edit your source and reload the page, the current
|
||||
package is recompiled and the listing is updated. It is not necessary
|
||||
|
@ -134,7 +133,7 @@ Each instruction is displayed with a link that causes your editor to
|
|||
navigate to the source line responsible for the instruction, according
|
||||
to the debug information.
|
||||
|
||||
<img title="View assembly" src="../assets/browse-assembly.png" width="80%">
|
||||
<img title="Browse assembly" src="../assets/browse-assembly.png" width="80%">
|
||||
|
||||
The example above shows the arm64 assembly listing of
|
||||
[`time.NewTimer`](https://pkg.go.dev/time#NewTimer).
|
||||
|
@ -142,11 +141,11 @@ Observe that the indicated instruction links to a source location
|
|||
inside a different function, `syncTimer`, because the compiler
|
||||
inlined the call from `NewTimer` to `syncTimer`.
|
||||
|
||||
Viewing assembly is not yet supported for generic functions, package
|
||||
Browsing assembly is not yet supported for generic functions, package
|
||||
initializers (`func init`), or functions in test packages.
|
||||
(Contributions welcome!)
|
||||
|
||||
Client support:
|
||||
- **VS Code**: Use the "Source Action... > View GOARCH assembly for f" menu.
|
||||
- **VS Code**: Use the "Source Action... > Browse GOARCH assembly for f" menu.
|
||||
- **Emacs + eglot**: Use `M-x go-browse-assembly` in [go-mode](https://github.com/dominikh/go-mode.el).
|
||||
- **Vim + coc.nvim**: ??
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
// The generate command updates the following files of documentation:
|
||||
//
|
||||
// gopls/doc/settings.md -- from linking gopls/internal/settings.DefaultOptions
|
||||
// gopls/doc/commands.md -- from loading gopls/internal/protocol/command
|
||||
// gopls/doc/analyzers.md -- from linking gopls/internal/settings.DefaultAnalyzers
|
||||
// gopls/doc/inlayHints.md -- from loading gopls/internal/settings.InlayHint
|
||||
// gopls/internal/doc/api.json -- all of the above in a single value, for 'gopls api-json'
|
||||
|
@ -41,7 +40,6 @@ import (
|
|||
"golang.org/x/tools/gopls/internal/doc"
|
||||
"golang.org/x/tools/gopls/internal/golang"
|
||||
"golang.org/x/tools/gopls/internal/mod"
|
||||
"golang.org/x/tools/gopls/internal/protocol/command/commandmeta"
|
||||
"golang.org/x/tools/gopls/internal/settings"
|
||||
"golang.org/x/tools/gopls/internal/util/maps"
|
||||
"golang.org/x/tools/gopls/internal/util/safetoken"
|
||||
|
@ -88,7 +86,6 @@ func doMain(write bool) (bool, error) {
|
|||
{"internal/doc/api.json", rewriteAPI},
|
||||
{"doc/settings.md", rewriteSettings},
|
||||
{"doc/codelenses.md", rewriteCodeLenses},
|
||||
{"doc/commands.md", rewriteCommands},
|
||||
{"doc/analyzers.md", rewriteAnalyzers},
|
||||
{"doc/inlayHints.md", rewriteInlayHints},
|
||||
} {
|
||||
|
@ -150,10 +147,6 @@ func loadAPI() (*doc.API, error) {
|
|||
Analyzers: loadAnalyzers(settings.DefaultAnalyzers), // no staticcheck analyzers
|
||||
}
|
||||
|
||||
api.Commands, err = loadCommands()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
api.Lenses, err = loadLenses(settingsPkg, defaults.Codelenses)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -441,84 +434,6 @@ func valueDoc(name, value, doc string) string {
|
|||
return fmt.Sprintf("`%s`: %s", value, doc)
|
||||
}
|
||||
|
||||
func loadCommands() ([]*doc.Command, error) {
|
||||
var commands []*doc.Command
|
||||
|
||||
cmds, err := commandmeta.Load()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Parse the objects it contains.
|
||||
for _, cmd := range cmds {
|
||||
cmdjson := &doc.Command{
|
||||
Command: cmd.Name,
|
||||
Title: cmd.Title,
|
||||
Doc: cmd.Doc,
|
||||
ArgDoc: argsDoc(cmd.Args),
|
||||
}
|
||||
if cmd.Result != nil {
|
||||
cmdjson.ResultDoc = typeDoc(cmd.Result, 0)
|
||||
}
|
||||
commands = append(commands, cmdjson)
|
||||
}
|
||||
return commands, nil
|
||||
}
|
||||
|
||||
func argsDoc(args []*commandmeta.Field) string {
|
||||
var b strings.Builder
|
||||
for i, arg := range args {
|
||||
b.WriteString(typeDoc(arg, 0))
|
||||
if i != len(args)-1 {
|
||||
b.WriteString(",\n")
|
||||
}
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
func typeDoc(arg *commandmeta.Field, level int) string {
|
||||
// Max level to expand struct fields.
|
||||
const maxLevel = 3
|
||||
if len(arg.Fields) > 0 {
|
||||
if level < maxLevel {
|
||||
return arg.FieldMod + structDoc(arg.Fields, level)
|
||||
}
|
||||
return "{ ... }"
|
||||
}
|
||||
under := arg.Type.Underlying()
|
||||
switch u := under.(type) {
|
||||
case *types.Slice:
|
||||
return fmt.Sprintf("[]%s", u.Elem().Underlying().String())
|
||||
}
|
||||
// TODO(adonovan): use (*types.Package).Name qualifier.
|
||||
return types.TypeString(under, nil)
|
||||
}
|
||||
|
||||
// TODO(adonovan): this format is strange; it's not Go, nor JSON, nor LSP. Rethink.
|
||||
func structDoc(fields []*commandmeta.Field, level int) string {
|
||||
var b strings.Builder
|
||||
b.WriteString("{\n")
|
||||
indent := strings.Repeat("\t", level)
|
||||
for _, fld := range fields {
|
||||
if fld.Doc != "" && level == 0 {
|
||||
doclines := strings.Split(fld.Doc, "\n")
|
||||
for _, line := range doclines {
|
||||
text := ""
|
||||
if line != "" {
|
||||
text = " " + line
|
||||
}
|
||||
fmt.Fprintf(&b, "%s\t//%s\n", indent, text)
|
||||
}
|
||||
}
|
||||
tag := strings.Split(fld.JSONTag, ",")[0]
|
||||
if tag == "" {
|
||||
tag = fld.Name
|
||||
}
|
||||
fmt.Fprintf(&b, "%s\t%q: %s,\n", indent, tag, typeDoc(fld, level+1))
|
||||
}
|
||||
fmt.Fprintf(&b, "%s}", indent)
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// loadLenses combines the syntactic comments from the settings
|
||||
// package with the default values from settings.DefaultOptions(), and
|
||||
// returns a list of Code Lens descriptors.
|
||||
|
@ -828,23 +743,6 @@ func rewriteCodeLenses(prevContent []byte, api *doc.API) ([]byte, error) {
|
|||
return replaceSection(prevContent, "Lenses", buf.Bytes())
|
||||
}
|
||||
|
||||
func rewriteCommands(prevContent []byte, api *doc.API) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
for _, command := range api.Commands {
|
||||
// Emit HTML anchor as GitHub markdown doesn't support
|
||||
// "# Heading {#anchor}" syntax.
|
||||
fmt.Fprintf(&buf, "<a id='%s'></a>\n", command.Command)
|
||||
fmt.Fprintf(&buf, "## `%s`: **%s**\n\n%v\n\n", command.Command, command.Title, command.Doc)
|
||||
if command.ArgDoc != "" {
|
||||
fmt.Fprintf(&buf, "Args:\n\n```\n%s\n```\n\n", command.ArgDoc)
|
||||
}
|
||||
if command.ResultDoc != "" {
|
||||
fmt.Fprintf(&buf, "Result:\n\n```\n%s\n```\n\n", command.ResultDoc)
|
||||
}
|
||||
}
|
||||
return replaceSection(prevContent, "Commands", buf.Bytes())
|
||||
}
|
||||
|
||||
func rewriteAnalyzers(prevContent []byte, api *doc.API) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
for _, analyzer := range api.Analyzers {
|
||||
|
|
|
@ -35,11 +35,9 @@ The execute command sends an LSP ExecuteCommand request to gopls,
|
|||
with a set of optional JSON argument values.
|
||||
Some commands return a result, also JSON.
|
||||
|
||||
Available commands are documented at:
|
||||
|
||||
https://github.com/golang/tools/blob/master/gopls/doc/commands.md
|
||||
|
||||
This interface is experimental and commands may change or disappear without notice.
|
||||
Gopls' command set is defined by the command.Interface type; see
|
||||
https://pkg.go.dev/golang.org/x/tools/gopls/internal/protocol/command#Interface.
|
||||
It is not a stable interface: commands may change or disappear without notice.
|
||||
|
||||
Examples:
|
||||
|
||||
|
|
|
@ -7,11 +7,9 @@ The execute command sends an LSP ExecuteCommand request to gopls,
|
|||
with a set of optional JSON argument values.
|
||||
Some commands return a result, also JSON.
|
||||
|
||||
Available commands are documented at:
|
||||
|
||||
https://github.com/golang/tools/blob/master/gopls/doc/commands.md
|
||||
|
||||
This interface is experimental and commands may change or disappear without notice.
|
||||
Gopls' command set is defined by the command.Interface type; see
|
||||
https://pkg.go.dev/golang.org/x/tools/gopls/internal/protocol/command#Interface.
|
||||
It is not a stable interface: commands may change or disappear without notice.
|
||||
|
||||
Examples:
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ var JSON string
|
|||
// TODO(adonovan): document these data types.
|
||||
type API struct {
|
||||
Options map[string][]*Option
|
||||
Commands []*Command
|
||||
Lenses []*Lens
|
||||
Analyzers []*Analyzer
|
||||
Hints []*Hint
|
||||
|
@ -54,14 +53,6 @@ type EnumValue struct {
|
|||
Doc string // doc comment; always starts with `Value`
|
||||
}
|
||||
|
||||
type Command struct {
|
||||
Command string // e.g. "gopls.run_tests"
|
||||
Title string
|
||||
Doc string
|
||||
ArgDoc string
|
||||
ResultDoc string
|
||||
}
|
||||
|
||||
type Lens struct {
|
||||
FileType string // e.g. "Go", "go.mod"
|
||||
Lens string
|
||||
|
|
|
@ -939,295 +939,6 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"Commands": [
|
||||
{
|
||||
"Command": "gopls.add_dependency",
|
||||
"Title": "Add a dependency",
|
||||
"Doc": "Adds a dependency to the go.mod file for a module.",
|
||||
"ArgDoc": "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// Additional args to pass to the go command.\n\t\"GoCmdArgs\": []string,\n\t// Whether to add a require directive.\n\t\"AddRequire\": bool,\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.add_import",
|
||||
"Title": "Add an import",
|
||||
"Doc": "Ask the server to add an import path to a given Go file. The method will\ncall applyEdit on the client so that clients don't have to apply the edit\nthemselves.",
|
||||
"ArgDoc": "{\n\t// ImportPath is the target import path that should\n\t// be added to the URI file\n\t\"ImportPath\": string,\n\t// URI is the file that the ImportPath should be\n\t// added to\n\t\"URI\": string,\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.add_telemetry_counters",
|
||||
"Title": "Update the given telemetry counters",
|
||||
"Doc": "Gopls will prepend \"fwd/\" to all the counters updated using this command\nto avoid conflicts with other counters gopls collects.",
|
||||
"ArgDoc": "{\n\t// Names and Values must have the same length.\n\t\"Names\": []string,\n\t\"Values\": []int64,\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.apply_fix",
|
||||
"Title": "Apply a fix",
|
||||
"Doc": "Applies a fix to a region of source code.",
|
||||
"ArgDoc": "{\n\t// The name of the fix to apply.\n\t//\n\t// For fixes suggested by analyzers, this is a string constant\n\t// advertised by the analyzer that matches the Category of\n\t// the analysis.Diagnostic with a SuggestedFix containing no edits.\n\t//\n\t// For fixes suggested by code actions, this is a string agreed\n\t// upon by the code action and golang.ApplyFix.\n\t\"Fix\": string,\n\t// The file URI for the document to fix.\n\t\"URI\": string,\n\t// The document range to scan for fixes.\n\t\"Range\": {\n\t\t\"start\": {\n\t\t\t\"line\": uint32,\n\t\t\t\"character\": uint32,\n\t\t},\n\t\t\"end\": {\n\t\t\t\"line\": uint32,\n\t\t\t\"character\": uint32,\n\t\t},\n\t},\n\t// Whether to resolve and return the edits.\n\t\"ResolveEdits\": bool,\n}",
|
||||
"ResultDoc": "{\n\t// Holds changes to existing resources.\n\t\"changes\": map[golang.org/x/tools/gopls/internal/protocol.DocumentURI][]golang.org/x/tools/gopls/internal/protocol.TextEdit,\n\t// Depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes\n\t// are either an array of `TextDocumentEdit`s to express changes to n different text documents\n\t// where each text document edit addresses a specific version of a text document. Or it can contain\n\t// above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations.\n\t//\n\t// Whether a client supports versioned document edits is expressed via\n\t// `workspace.workspaceEdit.documentChanges` client capability.\n\t//\n\t// If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then\n\t// only plain `TextEdit`s using the `changes` property are supported.\n\t\"documentChanges\": []{\n\t\t\"TextDocumentEdit\": {\n\t\t\t\"textDocument\": { ... },\n\t\t\t\"edits\": { ... },\n\t\t},\n\t\t\"CreateFile\": {\n\t\t\t\"kind\": string,\n\t\t\t\"uri\": string,\n\t\t\t\"options\": { ... },\n\t\t\t\"ResourceOperation\": { ... },\n\t\t},\n\t\t\"RenameFile\": {\n\t\t\t\"kind\": string,\n\t\t\t\"oldUri\": string,\n\t\t\t\"newUri\": string,\n\t\t\t\"options\": { ... },\n\t\t\t\"ResourceOperation\": { ... },\n\t\t},\n\t\t\"DeleteFile\": {\n\t\t\t\"kind\": string,\n\t\t\t\"uri\": string,\n\t\t\t\"options\": { ... },\n\t\t\t\"ResourceOperation\": { ... },\n\t\t},\n\t},\n\t// A map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and\n\t// delete file / folder operations.\n\t//\n\t// Whether clients honor this property depends on the client capability `workspace.changeAnnotationSupport`.\n\t//\n\t// @since 3.16.0\n\t\"changeAnnotations\": map[string]golang.org/x/tools/gopls/internal/protocol.ChangeAnnotation,\n}"
|
||||
},
|
||||
{
|
||||
"Command": "gopls.assembly",
|
||||
"Title": "Browse assembly listing of current function in a browser.",
|
||||
"Doc": "This command opens a web-based disassembly listing of the\nspecified function symbol (plus any nested lambdas and defers).\nThe machine architecture is determined by the view.",
|
||||
"ArgDoc": "string,\nstring,\nstring",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.change_signature",
|
||||
"Title": "Perform a \"change signature\" refactoring",
|
||||
"Doc": "This command is experimental, currently only supporting parameter removal.\nIts signature will certainly change in the future (pun intended).",
|
||||
"ArgDoc": "{\n\t\"RemoveParameter\": {\n\t\t\"uri\": string,\n\t\t\"range\": {\n\t\t\t\"start\": { ... },\n\t\t\t\"end\": { ... },\n\t\t},\n\t},\n\t// Whether to resolve and return the edits.\n\t\"ResolveEdits\": bool,\n}",
|
||||
"ResultDoc": "{\n\t// Holds changes to existing resources.\n\t\"changes\": map[golang.org/x/tools/gopls/internal/protocol.DocumentURI][]golang.org/x/tools/gopls/internal/protocol.TextEdit,\n\t// Depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes\n\t// are either an array of `TextDocumentEdit`s to express changes to n different text documents\n\t// where each text document edit addresses a specific version of a text document. Or it can contain\n\t// above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations.\n\t//\n\t// Whether a client supports versioned document edits is expressed via\n\t// `workspace.workspaceEdit.documentChanges` client capability.\n\t//\n\t// If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then\n\t// only plain `TextEdit`s using the `changes` property are supported.\n\t\"documentChanges\": []{\n\t\t\"TextDocumentEdit\": {\n\t\t\t\"textDocument\": { ... },\n\t\t\t\"edits\": { ... },\n\t\t},\n\t\t\"CreateFile\": {\n\t\t\t\"kind\": string,\n\t\t\t\"uri\": string,\n\t\t\t\"options\": { ... },\n\t\t\t\"ResourceOperation\": { ... },\n\t\t},\n\t\t\"RenameFile\": {\n\t\t\t\"kind\": string,\n\t\t\t\"oldUri\": string,\n\t\t\t\"newUri\": string,\n\t\t\t\"options\": { ... },\n\t\t\t\"ResourceOperation\": { ... },\n\t\t},\n\t\t\"DeleteFile\": {\n\t\t\t\"kind\": string,\n\t\t\t\"uri\": string,\n\t\t\t\"options\": { ... },\n\t\t\t\"ResourceOperation\": { ... },\n\t\t},\n\t},\n\t// A map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and\n\t// delete file / folder operations.\n\t//\n\t// Whether clients honor this property depends on the client capability `workspace.changeAnnotationSupport`.\n\t//\n\t// @since 3.16.0\n\t\"changeAnnotations\": map[string]golang.org/x/tools/gopls/internal/protocol.ChangeAnnotation,\n}"
|
||||
},
|
||||
{
|
||||
"Command": "gopls.check_upgrades",
|
||||
"Title": "Check for upgrades",
|
||||
"Doc": "Checks for module upgrades.",
|
||||
"ArgDoc": "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// The modules to check.\n\t\"Modules\": []string,\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.client_open_url",
|
||||
"Title": "Request that the client open a URL in a browser.",
|
||||
"Doc": "",
|
||||
"ArgDoc": "string",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.diagnose_files",
|
||||
"Title": "Cause server to publish diagnostics for the specified files.",
|
||||
"Doc": "This command is needed by the 'gopls {check,fix}' CLI subcommands.",
|
||||
"ArgDoc": "{\n\t\"Files\": []string,\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.doc",
|
||||
"Title": "Browse package documentation.",
|
||||
"Doc": "Opens the Go package documentation page for the current\npackage in a browser.",
|
||||
"ArgDoc": "{\n\t\"uri\": string,\n\t\"range\": {\n\t\t\"start\": {\n\t\t\t\"line\": uint32,\n\t\t\t\"character\": uint32,\n\t\t},\n\t\t\"end\": {\n\t\t\t\"line\": uint32,\n\t\t\t\"character\": uint32,\n\t\t},\n\t},\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.edit_go_directive",
|
||||
"Title": "Run go mod edit -go=version",
|
||||
"Doc": "Runs `go mod edit -go=version` for a module.",
|
||||
"ArgDoc": "{\n\t// Any document URI within the relevant module.\n\t\"URI\": string,\n\t// The version to pass to `go mod edit -go`.\n\t\"Version\": string,\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.extract_to_new_file",
|
||||
"Title": "Move selected declarations to a new file",
|
||||
"Doc": "Used by the code action of the same name.",
|
||||
"ArgDoc": "{\n\t\"uri\": string,\n\t\"range\": {\n\t\t\"start\": {\n\t\t\t\"line\": uint32,\n\t\t\t\"character\": uint32,\n\t\t},\n\t\t\"end\": {\n\t\t\t\"line\": uint32,\n\t\t\t\"character\": uint32,\n\t\t},\n\t},\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.fetch_vulncheck_result",
|
||||
"Title": "Get known vulncheck result",
|
||||
"Doc": "Fetch the result of latest vulnerability check (`govulncheck`).",
|
||||
"ArgDoc": "{\n\t// The file URI.\n\t\"URI\": string,\n}",
|
||||
"ResultDoc": "map[golang.org/x/tools/gopls/internal/protocol.DocumentURI]*golang.org/x/tools/gopls/internal/vulncheck.Result"
|
||||
},
|
||||
{
|
||||
"Command": "gopls.free_symbols",
|
||||
"Title": "Browse free symbols referenced by the selection in a browser.",
|
||||
"Doc": "This command is a query over a selected range of Go source\ncode. It reports the set of \"free\" symbols of the\nselection: the set of symbols that are referenced within\nthe selection but are declared outside of it. This\ninformation is useful for understanding at a glance what a\nblock of code depends on, perhaps as a precursor to\nextracting it into a separate function.",
|
||||
"ArgDoc": "string,\n{\n\t\"uri\": string,\n\t\"range\": {\n\t\t\"start\": {\n\t\t\t\"line\": uint32,\n\t\t\t\"character\": uint32,\n\t\t},\n\t\t\"end\": {\n\t\t\t\"line\": uint32,\n\t\t\t\"character\": uint32,\n\t\t},\n\t},\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.gc_details",
|
||||
"Title": "Toggle gc_details",
|
||||
"Doc": "Toggle the calculation of gc annotations.",
|
||||
"ArgDoc": "string",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.generate",
|
||||
"Title": "Run go generate",
|
||||
"Doc": "Runs `go generate` for a given directory.",
|
||||
"ArgDoc": "{\n\t// URI for the directory to generate.\n\t\"Dir\": string,\n\t// Whether to generate recursively (go generate ./...)\n\t\"Recursive\": bool,\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.go_get_package",
|
||||
"Title": "'go get' a package",
|
||||
"Doc": "Runs `go get` to fetch a package.",
|
||||
"ArgDoc": "{\n\t// Any document URI within the relevant module.\n\t\"URI\": string,\n\t// The package to go get.\n\t\"Pkg\": string,\n\t\"AddRequire\": bool,\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.list_imports",
|
||||
"Title": "List imports of a file and its package",
|
||||
"Doc": "Retrieve a list of imports in the given Go file, and the package it\nbelongs to.",
|
||||
"ArgDoc": "{\n\t// The file URI.\n\t\"URI\": string,\n}",
|
||||
"ResultDoc": "{\n\t// Imports is a list of imports in the requested file.\n\t\"Imports\": []{\n\t\t\"Path\": string,\n\t\t\"Name\": string,\n\t},\n\t// PackageImports is a list of all imports in the requested file's package.\n\t\"PackageImports\": []{\n\t\t\"Path\": string,\n\t},\n}"
|
||||
},
|
||||
{
|
||||
"Command": "gopls.list_known_packages",
|
||||
"Title": "List known packages",
|
||||
"Doc": "Retrieve a list of packages that are importable from the given URI.",
|
||||
"ArgDoc": "{\n\t// The file URI.\n\t\"URI\": string,\n}",
|
||||
"ResultDoc": "{\n\t// Packages is a list of packages relative\n\t// to the URIArg passed by the command request.\n\t// In other words, it omits paths that are already\n\t// imported or cannot be imported due to compiler\n\t// restrictions.\n\t\"Packages\": []string,\n}"
|
||||
},
|
||||
{
|
||||
"Command": "gopls.maybe_prompt_for_telemetry",
|
||||
"Title": "Prompt user to enable telemetry",
|
||||
"Doc": "Checks for the right conditions, and then prompts the user\nto ask if they want to enable Go telemetry uploading. If\nthe user responds 'Yes', the telemetry mode is set to \"on\".",
|
||||
"ArgDoc": "",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.mem_stats",
|
||||
"Title": "Fetch memory statistics",
|
||||
"Doc": "Call runtime.GC multiple times and return memory statistics as reported by\nruntime.MemStats.\n\nThis command is used for benchmarking, and may change in the future.",
|
||||
"ArgDoc": "",
|
||||
"ResultDoc": "{\n\t\"HeapAlloc\": uint64,\n\t\"HeapInUse\": uint64,\n\t\"TotalAlloc\": uint64,\n}"
|
||||
},
|
||||
{
|
||||
"Command": "gopls.modules",
|
||||
"Title": "Return information about modules within a directory",
|
||||
"Doc": "This command returns an empty result if there is no module,\nor if module mode is disabled.\nThe result does not includes the modules that are not\nassociated with any Views on the server yet.",
|
||||
"ArgDoc": "{\n\t// Dir is the directory in which to search for go.mod files.\n\t\"Dir\": string,\n\t// MaxDepth is the directory walk limit.\n\t// A value of 0 means inspect only Dir.\n\t// 1 means inspect its child directories too, and so on.\n\t// A negative value removes the limit.\n\t\"MaxDepth\": int,\n}",
|
||||
"ResultDoc": "{\n\t\"Modules\": []{\n\t\t\"Path\": string,\n\t\t\"Version\": string,\n\t\t\"GoMod\": string,\n\t},\n}"
|
||||
},
|
||||
{
|
||||
"Command": "gopls.packages",
|
||||
"Title": "Return information about packages",
|
||||
"Doc": "This command returns an empty result if the specified files\nor directories are not associated with any Views on the\nserver yet.",
|
||||
"ArgDoc": "{\n\t// Files is a list of files and directories whose associated\n\t// packages should be described by the result.\n\t//\n\t// In some cases, a file may belong to more than one package;\n\t// the result may describe any of them.\n\t\"Files\": []string,\n\t// Enumerate all packages under the directry loadable with\n\t// the ... pattern.\n\t// The search does not cross the module boundaries and\n\t// does not return packages that are not yet loaded.\n\t// (e.g. those excluded by the gopls directory filter setting,\n\t// or the go.work configuration)\n\t\"Recursive\": bool,\n\t// Mode controls the types of information returned for each package.\n\t\"Mode\": uint64,\n}",
|
||||
"ResultDoc": "{\n\t// Packages is an unordered list of package metadata.\n\t\"Packages\": []{\n\t\t\"Path\": string,\n\t\t\"ModulePath\": string,\n\t\t\"TestFiles\": []{\n\t\t\t\"URI\": string,\n\t\t\t\"Tests\": { ... },\n\t\t},\n\t},\n\t// Modules maps module path to module metadata for\n\t// all the modules of the returned Packages.\n\t\"Module\": map[string]golang.org/x/tools/gopls/internal/protocol/command.Module,\n}"
|
||||
},
|
||||
{
|
||||
"Command": "gopls.regenerate_cgo",
|
||||
"Title": "Regenerate cgo",
|
||||
"Doc": "Regenerates cgo definitions.",
|
||||
"ArgDoc": "{\n\t// The file URI.\n\t\"URI\": string,\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.remove_dependency",
|
||||
"Title": "Remove a dependency",
|
||||
"Doc": "Removes a dependency from the go.mod file of a module.",
|
||||
"ArgDoc": "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// The module path to remove.\n\t\"ModulePath\": string,\n\t// If the module is tidied apart from the one unused diagnostic, we can\n\t// run `go get module@none`, and then run `go mod tidy`. Otherwise, we\n\t// must make textual edits.\n\t\"OnlyDiagnostic\": bool,\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.reset_go_mod_diagnostics",
|
||||
"Title": "Reset go.mod diagnostics",
|
||||
"Doc": "Reset diagnostics in the go.mod file of a module.",
|
||||
"ArgDoc": "{\n\t\"URIArg\": {\n\t\t\"URI\": string,\n\t},\n\t// Optional: source of the diagnostics to reset.\n\t// If not set, all resettable go.mod diagnostics will be cleared.\n\t\"DiagnosticSource\": string,\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.run_go_work_command",
|
||||
"Title": "Run `go work [args...]`, and apply the resulting go.work",
|
||||
"Doc": "edits to the current go.work file",
|
||||
"ArgDoc": "{\n\t\"ViewID\": string,\n\t\"InitFirst\": bool,\n\t\"Args\": []string,\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.run_govulncheck",
|
||||
"Title": "Run vulncheck",
|
||||
"Doc": "Run vulnerability check (`govulncheck`).\n\nThis command is asynchronous; clients must wait for the 'end' progress notification.",
|
||||
"ArgDoc": "{\n\t// Any document in the directory from which govulncheck will run.\n\t\"URI\": string,\n\t// Package pattern. E.g. \"\", \".\", \"./...\".\n\t\"Pattern\": string,\n}",
|
||||
"ResultDoc": "{\n\t// Token holds the progress token for LSP workDone reporting of the vulncheck\n\t// invocation.\n\t\"Token\": interface{},\n}"
|
||||
},
|
||||
{
|
||||
"Command": "gopls.run_tests",
|
||||
"Title": "Run test(s)",
|
||||
"Doc": "Runs `go test` for a specific set of test or benchmark functions.\n\nThis command is asynchronous; clients must wait for the 'end' progress notification.",
|
||||
"ArgDoc": "{\n\t// The test file containing the tests to run.\n\t\"URI\": string,\n\t// Specific test names to run, e.g. TestFoo.\n\t\"Tests\": []string,\n\t// Specific benchmarks to run, e.g. BenchmarkFoo.\n\t\"Benchmarks\": []string,\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.scan_imports",
|
||||
"Title": "force a sychronous scan of the imports cache.",
|
||||
"Doc": "This command is intended for use by gopls tests only.",
|
||||
"ArgDoc": "",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.start_debugging",
|
||||
"Title": "Start the gopls debug server",
|
||||
"Doc": "Start the gopls debug server if it isn't running, and return the debug\naddress.",
|
||||
"ArgDoc": "{\n\t// Optional: the address (including port) for the debug server to listen on.\n\t// If not provided, the debug server will bind to \"localhost:0\", and the\n\t// full debug URL will be contained in the result.\n\t//\n\t// If there is more than one gopls instance along the serving path (i.e. you\n\t// are using a daemon), each gopls instance will attempt to start debugging.\n\t// If Addr specifies a port, only the daemon will be able to bind to that\n\t// port, and each intermediate gopls instance will fail to start debugging.\n\t// For this reason it is recommended not to specify a port (or equivalently,\n\t// to specify \":0\").\n\t//\n\t// If the server was already debugging this field has no effect, and the\n\t// result will contain the previously configured debug URL(s).\n\t\"Addr\": string,\n}",
|
||||
"ResultDoc": "{\n\t// The URLs to use to access the debug servers, for all gopls instances in\n\t// the serving path. For the common case of a single gopls instance (i.e. no\n\t// daemon), this will be exactly one address.\n\t//\n\t// In the case of one or more gopls instances forwarding the LSP to a daemon,\n\t// URLs will contain debug addresses for each server in the serving path, in\n\t// serving order. The daemon debug address will be the last entry in the\n\t// slice. If any intermediate gopls instance fails to start debugging, no\n\t// error will be returned but the debug URL for that server in the URLs slice\n\t// will be empty.\n\t\"URLs\": []string,\n}"
|
||||
},
|
||||
{
|
||||
"Command": "gopls.start_profile",
|
||||
"Title": "Start capturing a profile of gopls' execution",
|
||||
"Doc": "Start a new pprof profile. Before using the resulting file, profiling must\nbe stopped with a corresponding call to StopProfile.\n\nThis command is intended for internal use only, by the gopls benchmark\nrunner.",
|
||||
"ArgDoc": "struct{}",
|
||||
"ResultDoc": "struct{}"
|
||||
},
|
||||
{
|
||||
"Command": "gopls.stop_profile",
|
||||
"Title": "Stop an ongoing profile",
|
||||
"Doc": "This command is intended for internal use only, by the gopls benchmark\nrunner.",
|
||||
"ArgDoc": "struct{}",
|
||||
"ResultDoc": "{\n\t// File is the profile file name.\n\t\"File\": string,\n}"
|
||||
},
|
||||
{
|
||||
"Command": "gopls.test",
|
||||
"Title": "Run test(s) (legacy)",
|
||||
"Doc": "Runs `go test` for a specific set of test or benchmark functions.\n\nThis command is asynchronous; wait for the 'end' progress notification.\n\nThis command is an alias for RunTests; the only difference\nis the form of the parameters.\n\nTODO(adonovan): eliminate it.",
|
||||
"ArgDoc": "string,\n[]string,\n[]string",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.tidy",
|
||||
"Title": "Run go mod tidy",
|
||||
"Doc": "Runs `go mod tidy` for a module.",
|
||||
"ArgDoc": "{\n\t// The file URIs.\n\t\"URIs\": []string,\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.toggle_gc_details",
|
||||
"Title": "Toggle gc_details",
|
||||
"Doc": "Toggle the calculation of gc annotations.",
|
||||
"ArgDoc": "{\n\t// The file URI.\n\t\"URI\": string,\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.update_go_sum",
|
||||
"Title": "Update go.sum",
|
||||
"Doc": "Updates the go.sum file for a module.",
|
||||
"ArgDoc": "{\n\t// The file URIs.\n\t\"URIs\": []string,\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.upgrade_dependency",
|
||||
"Title": "Upgrade a dependency",
|
||||
"Doc": "Upgrades a dependency in the go.mod file for a module.",
|
||||
"ArgDoc": "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// Additional args to pass to the go command.\n\t\"GoCmdArgs\": []string,\n\t// Whether to add a require directive.\n\t\"AddRequire\": bool,\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.vendor",
|
||||
"Title": "Run go mod vendor",
|
||||
"Doc": "Runs `go mod vendor` for a module.",
|
||||
"ArgDoc": "{\n\t// The file URI.\n\t\"URI\": string,\n}",
|
||||
"ResultDoc": ""
|
||||
},
|
||||
{
|
||||
"Command": "gopls.views",
|
||||
"Title": "List current Views on the server.",
|
||||
"Doc": "This command is intended for use by gopls tests only.",
|
||||
"ArgDoc": "",
|
||||
"ResultDoc": "[]{\n\t\"ID\": string,\n\t\"Type\": string,\n\t\"Root\": string,\n\t\"Folder\": string,\n\t\"EnvOverlay\": []string,\n}"
|
||||
},
|
||||
{
|
||||
"Command": "gopls.workspace_stats",
|
||||
"Title": "Fetch workspace statistics",
|
||||
"Doc": "Query statistics about workspace builds, modules, packages, and files.\n\nThis command is intended for internal use only, by the gopls stats\ncommand.",
|
||||
"ArgDoc": "",
|
||||
"ResultDoc": "{\n\t\"Files\": {\n\t\t\"Total\": int,\n\t\t\"Largest\": int,\n\t\t\"Errs\": int,\n\t},\n\t\"Views\": []{\n\t\t\"GoCommandVersion\": string,\n\t\t\"AllPackages\": {\n\t\t\t\"Packages\": int,\n\t\t\t\"LargestPackage\": int,\n\t\t\t\"CompiledGoFiles\": int,\n\t\t\t\"Modules\": int,\n\t\t},\n\t\t\"WorkspacePackages\": {\n\t\t\t\"Packages\": int,\n\t\t\t\"LargestPackage\": int,\n\t\t\t\"CompiledGoFiles\": int,\n\t\t\t\"Modules\": int,\n\t\t},\n\t\t\"Diagnostics\": int,\n\t},\n}"
|
||||
}
|
||||
],
|
||||
"Lenses": [
|
||||
{
|
||||
"FileType": "Go",
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
// Package commandmeta provides metadata about LSP commands, by
|
||||
// statically analyzing the command.Interface type.
|
||||
//
|
||||
// It is used to generate JSONRPC dispatch and marshaling.
|
||||
// TODO(adonovan): combine with gopls/internal/protocol/command/gen.
|
||||
package commandmeta
|
||||
|
||||
import (
|
||||
|
|
|
@ -24,21 +24,21 @@ import (
|
|||
// Interface defines the interface gopls exposes for the
|
||||
// workspace/executeCommand request.
|
||||
//
|
||||
// This interface is used to generate marshaling/unmarshaling code, dispatch,
|
||||
// and documentation, and so has some additional restrictions:
|
||||
// This interface is used to generate logic for marshaling,
|
||||
// unmarshaling, and dispatch, so it has some additional restrictions:
|
||||
//
|
||||
// 1. All method arguments must be JSON serializable.
|
||||
//
|
||||
// 2. Methods must return either error or (T, error), where T is a
|
||||
// JSON serializable type.
|
||||
//
|
||||
// 3. The first line of the doc string is special.
|
||||
// Everything after the colon is considered the command 'Title'.
|
||||
// For example:
|
||||
//
|
||||
// The doc comment on each method is eventually published at
|
||||
// https://github.com/golang/tools/blob/master/gopls/doc/commands.md,
|
||||
// so please be consistent in using this form:
|
||||
// Command: Capitalized verb phrase with no period
|
||||
//
|
||||
// Command: Capitalized verb phrase with no period
|
||||
//
|
||||
// Longer description here...
|
||||
// Longer description here...
|
||||
type Interface interface {
|
||||
// ApplyFix: Apply a fix
|
||||
//
|
||||
|
|
Загрузка…
Ссылка в новой задаче