Workspace Symbols
Workspace Symbols 请求
工作区符号请求从客户端发送到服务器,以列出与查询字符串匹配的项目范围符号。从 3.17.0 开始,服务器还可以为 workspaceSymbol/resolve
请求提供处理程序。这允许服务器返回工作区符号,而不带 workspace/symbol
请求范围。然后,客户端需要在必要时使用 workspaceSymbol/resolve
请求解析范围。只有当客户端通过 workspace.symbol.resolveSupport
功能通告支持此新模型时,服务器才能使用此新模型。
客户端能力(Client capability):
- 属性路径:
workspace.symbol
- 属性类型:
WorkspaceSymbolClientCapabilities
, 定义如下:
interface WorkspaceSymbolClientCapabilities {
/**
* Symbol request supports dynamic registration.
*/
dynamicRegistration?: boolean;
/**
* Specific capabilities for the `SymbolKind` in the `workspace/symbol`
* request.
*/
symbolKind?: {
/**
* The symbol kind values the client supports. When this
* property exists the client also guarantees that it will
* handle values outside its set gracefully and falls back
* to a default value when unknown.
*
* If this property is not present the client only supports
* the symbol kinds from `File` to `Array` as defined in
* the initial version of the protocol.
*/
valueSet?: SymbolKind[];
};
/**
* The client supports tags on `SymbolInformation` and `WorkspaceSymbol`.
* Clients supporting tags have to handle unknown tags gracefully.
*
* @since 3.16.0
*/
tagSupport?: {
/**
* The tags supported by the client.
*/
valueSet: SymbolTag[];
};
/**
* The client support partial workspace symbols. The client will send the
* request `workspaceSymbol/resolve` to the server to resolve additional
* properties.
*
* @since 3.17.0 - proposedState
*/
resolveSupport?: {
/**
* The properties that a client can resolve lazily. Usually
* `location.range`
*/
properties: string[];
};
}
服务端能力(Server capability):
- 属性路径:
workspaceSymbolProvider
- 属性类型:
boolean | WorkspaceSymbolOptions
, 定义如下:
export interface WorkspaceSymbolOptions extends WorkDoneProgressOptions {
/**
* The server provides support to resolve additional
* information for a workspace symbol.
*
* @since 3.17.0
*/
resolveProvider?: boolean;
}
注册选项(Registration Options): WorkspaceSymbolRegistrationOptions
, 定义如下:
export interface WorkspaceSymbolRegistrationOptions
extends WorkspaceSymbolOptions {
}
请求(Request):
- method: "workspace/symbol"
- params:
WorkspaceSymbolParams
, 定义如下:
/**
* The parameters of a Workspace Symbol Request.
*/
interface WorkspaceSymbolParams extends WorkDoneProgressParams,
PartialResultParams {
/**
* A query string to filter symbols by. Clients may send an empty
* string here to request all symbols.
*/
query: string;
}
响应(Response):
- result:
SymbolInformation[] | WorkspaceSymbol[] | null
, 有关SymbolInformation
的定义,请参阅上文。建议您使用新的WorkspaceSymbol
。但是,工作区符号是否可以返回没有范围的位置取决于客户端功能workspace.symbol.resolveSupport
。WorkspaceSymbol
,定义如下:
/**
* A special workspace symbol that supports locations without a range
*
* @since 3.17.0
*/
export interface WorkspaceSymbol {
/**
* The name of this symbol.
*/
name: string;
/**
* The kind of this symbol.
*/
kind: SymbolKind;
/**
* Tags for this completion item.
*/
tags?: SymbolTag[];
/**
* The name of the symbol containing this symbol. This information is for
* user interface purposes (e.g. to render a qualifier in the user interface
* if necessary). It can't be used to re-infer a hierarchy for the document
* symbols.
*/
containerName?: string;
/**
* The location of this symbol. Whether a server is allowed to
* return a location without a range depends on the client
* capability `workspace.symbol.resolveSupport`.
*
* See also `SymbolInformation.location`.
*/
location: Location | { uri: DocumentUri };
/**
* A data entry field that is preserved on a workspace symbol between a
* workspace symbol request and a workspace symbol resolve request.
*/
data?: LSPAny;
}
- partial result:
SymbolInformation[] | WorkspaceSymbol[]
- error:
code
和message
,以防在请求期间发生异常。
Workspace Symbol Resolve 请求
请求从客户端发送到服务器,以解析给定工作区符号的其他信息。
请求(Request):
- method: "workspaceSymbol/resolve"
- params:
WorkspaceSymbol
响应(Response):
- result:
WorkspaceSymbol
- error:
code
和message
,以防在请求期间发生异常。