Execute command 请求
workspace/executeCommand
请求从客户端发送到服务器,以触发服务器上的命令执行。在大多数情况下,服务器会创建一个 WorkspaceEdit
结构,并使用从服务器发送到客户端的请求 workspace/applyEdit
将更改应用于工作区。
客户端能力(Client capability):
- 属性路径:
workspace.executeCommand
- 属性类型:
ExecuteCommandClientCapabilities
, 定义如下:
export interface ExecuteCommandClientCapabilities {
/**
* Execute command supports dynamic registration.
*/
dynamicRegistration?: boolean;
}
服务端能力(Server capability):
- 属性路径:
executeCommandProvider
- 属性类型:
ExecuteCommandOptions
, 定义如下:
export interface ExecuteCommandOptions extends WorkDoneProgressOptions {
/**
* The commands to be executed on the server
*/
commands: string[];
}
注册选项(Registration Options): ExecuteCommandRegistrationOptions
, 定义如下:
/**
* Execute command registration options.
*/
export interface ExecuteCommandRegistrationOptions
extends ExecuteCommandOptions {
}
请求(Request):
- method: "workspace/executeCommand"
- params:
ExecuteCommandParams
, 定义如下:
export interface ExecuteCommandParams extends WorkDoneProgressParams {
/**
* The identifier of the actual command handler.
*/
command: string;
/**
* Arguments that the command should be invoked with.
*/
arguments?: LSPAny[];
}
当命令从服务器返回到客户端时,通常指定参数。返回命令的示例请求包括 textDocument/codeAction
或 textDocument/codeLens
。
响应(Response):
- result:
LSPAny