Code Lens
Code Lens 请求
代码信息指示器请求从客户端发送到服务器,以计算给定文本文档的代码信息指示器。
客户端能力(Client capability):
- 属性路径:
textDocument.codeLens
- 属性类型:
CodeLensClientCapabilities
, 定义如下:
export interface CodeLensClientCapabilities {
/**
* Whether code lens supports dynamic registration.
*/
dynamicRegistration?: boolean;
}
服务端能力(Server capability):
- 属性路径:
codeLensProvider
- 属性类型:
CodeLensOptions
, 定义如下:
export interface CodeLensOptions extends WorkDoneProgressOptions {
/**
* Code lens has a resolve provider as well.
*/
resolveProvider?: boolean;
}
注册选项(Registration Options): CodeLensRegistrationOptions
, 定义如下:
export interface CodeLensRegistrationOptions extends
TextDocumentRegistrationOptions, CodeLensOptions {
}
请求(Request):
- method: "textDocument/codeLens"
- params:
CodeLensParams
, 定义如下:
interface CodeLensParams extends WorkDoneProgressParams, PartialResultParams {
/**
* The document to request code lens for.
*/
textDocument: TextDocumentIdentifier;
}
响应(Response):
- result:
CodeLens[] | null
, 定义如下:
/**
* A code lens represents a command that should be shown along with
* source text, like the number of references, a way to run tests, etc.
*
* A code lens is _unresolved_ when no command is associated to it. For
* performance reasons the creation of a code lens and resolving should be done
* in two stages.
*/
interface CodeLens {
/**
* The range in which this code lens is valid. Should only span a single
* line.
*/
range: Range;
/**
* The command this code lens represents.
*/
command?: Command;
/**
* A data entry field that is preserved on a code lens item between
* a code lens and a code lens resolve request.
*/
data?: LSPAny;
}
- partial result:
CodeLens[]
- error:
code
和message
,以防在请求期间发生异常。
Code Lens Resolve 请求
代码信息指示器解析请求从客户端发送到服务器,以解析给定代码信息指示器项的命令。
请求(Request):
- method: "codeLens/resolve"
- params:
CodeLens
响应(Response):
- result:
CodeLens
, 定义如下: - error:
code
和message
,以防在请求期间发生异常。
Code Lens Refresh 请求
从版本 3.16.0 开始
workspace/codeLens/refresh
请求从服务器发送到客户端。服务器可以使用它来要求客户端刷新当前显示在编辑器中的代码信息指示器。因此,客户端应要求服务器重新计算这些编辑器的代码信息指示器。如果服务器检测到需要重新计算所有代码信息指示器的配置更改,这将非常有用。请注意,例如,如果编辑器当前不可见,客户端仍然可以自由延迟代码信息指示器的重新计算。
客户端能力(Client capability):
- 属性路径:
workspace.codeLens
- 属性类型:
CodeLensWorkspaceClientCapabilities
, 定义如下:
export interface CodeLensWorkspaceClientCapabilities {
/**
* Whether the client implementation supports a refresh request sent from the
* server to the client.
*
* Note that this event is global and will force the client to refresh all
* code lenses currently shown. It should be used with absolute care and is
* useful for situation where a server for example detect a project wide
* change that requires such a calculation.
*/
refreshSupport?: boolean;
}
请求(Request):
- method: "workspace/codeLens/refresh"
- params: none
响应(Response):
- result: void
- error:
code
和message
,以防在请求期间发生异常。