Monikers
从版本 3.16.0 开始
语言服务器索引格式(LSIF) 引入了 符号名称对象 的概念,以帮助跨不同索引关联符号。此请求为 LSP 服务器实现添加了功能,以便在给定文本文档位置的情况下提供相同的符号名称对象信息。客户端可以利用此方法获取用户正在编辑的文件的当前位置的名称,并在依赖于 LSIF 索引和链接符号的其他服务中执行进一步的代码导航查询。
请求从客户端发送到服务器,以获取给定文本文档位置的符号名称对象。将返回一个符号名称对象类型的数组作为响应,以指示给定位置可能的符合名称对象。如果无法计算符号名称对象,则应返回空数组或 null。
客户端能力(Client capability):
- 属性路径:
textDocument.moniker
- 属性类型:
MonikerClientCapabilities
, 定义如下:
interface MonikerClientCapabilities {
/**
* Whether implementation supports dynamic registration. If this is set to
* `true` the client supports the new `(TextDocumentRegistrationOptions &
* StaticRegistrationOptions)` return value for the corresponding server
* capability as well.
*/
dynamicRegistration?: boolean;
}
服务端能力(Server capability):
- 属性路径:
monikerProvider
- 属性类型:
boolean | MonikerOptions | MonikerRegistrationOptions
, 定义如下:
export interface MonikerOptions extends WorkDoneProgressOptions {
}
注册选项(Registration Options): MonikerRegistrationOptions
, 定义如下:
export interface MonikerRegistrationOptions extends
TextDocumentRegistrationOptions, MonikerOptions {
}
请求(Request):
- method: "textDocument/moniker"
- params:
MonikerParams
, 定义如下:
export interface MonikerParams extends TextDocumentPositionParams,
WorkDoneProgressParams, PartialResultParams {
}
响应(Response):
- result:
Moniker[] | null
, 定义如下:
/**
* Moniker definition to match LSIF 0.5 moniker definition.
*/
export interface Moniker {
/**
* The scheme of the moniker. For example tsc or .Net
*/
scheme: string;
/**
* The identifier of the moniker. The value is opaque in LSIF however
* schema owners are allowed to define the structure if they want.
*/
identifier: string;
/**
* The scope in which the moniker is unique
*/
unique: UniquenessLevel;
/**
* The moniker kind if known.
*/
kind?: MonikerKind;
}
/**
* Moniker uniqueness level to define scope of the moniker.
*/
export enum UniquenessLevel {
/**
* The moniker is only unique inside a document
*/
document = 'document',
/**
* The moniker is unique inside a project for which a dump got created
*/
project = 'project',
/**
* The moniker is unique inside the group to which a project belongs
*/
group = 'group',
/**
* The moniker is unique inside the moniker scheme.
*/
scheme = 'scheme',
/**
* The moniker is globally unique
*/
global = 'global'
}
/**
* The moniker kind.
*/
export enum MonikerKind {
/**
* The moniker represent a symbol that is imported into a project
*/
import = 'import',
/**
* The moniker represents a symbol that is exported from a project
*/
export = 'export',
/**
* The moniker represents a symbol that is local to a project (e.g. a local
* variable of a function, a class not visible outside the project, ...)
*/
local = 'local'
}
- partial result:
Moniker[]
- error:
code
和message
,以防在请求期间发生异常。
提示:
此方法的服务器实现应确保名称对象计算与相应 LSIF 实现中使用的名称计算匹配,以确保符号可以在 IDE 会话和 LSIF 索引之间正确关联。