Goto Definition 请求
转到定义请求从客户端发送到服务器,以解析给定文本文档位置的符号的定义位置。

结果类型 LocationLink[] 是在 3.14.0 版中引入的,它依赖于相应的客户端功能 textDocument.definition.linkSupport。
客户端能力(Client capability):
- 属性路径:
textDocument.definition - 属性类型:
DefinitionClientCapabilities, 定义如下:
export interface DefinitionClientCapabilities {
/**
* Whether definition supports dynamic registration.
*/
dynamicRegistration?: boolean;
/**
* The client supports additional metadata in the form of definition links.
*
* @since 3.14.0
*/
linkSupport?: boolean;
}
服务端能力(Server capability):
- 属性路径:
definitionProvider - 属性类型:
boolean | DefinitionOptions,DefinitionOptions定义如下:
export interface DefinitionOptions extends WorkDoneProgressOptions {
}
注册选项(Registration Options): DefinitionRegistrationOptions, 定义如下:
export interface DefinitionRegistrationOptions extends
TextDocumentRegistrationOptions, DefinitionOptions {
}
请求(Request):
- method: "textDocument/definition"
- params:
DefinitionParams, 定义如下:
export interface DefinitionParams extends TextDocumentPositionParams,
WorkDoneProgressParams, PartialResultParams {
}
响应(Response):
- result:
Location | Location[] | LocationLink[] | null - partial result:
Location[] | LocationLink[] - error:
code和message,以防在请求期间发生异常。