1use crate::{
2 LSPAny, Location, OneOf, PartialResultParams, SymbolInformation, SymbolKind,
3 SymbolKindCapability, SymbolTag, TagSupport, Url, WorkDoneProgressParams,
4};
5
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
9#[serde(rename_all = "camelCase")]
10pub struct WorkspaceSymbolClientCapabilities {
11 /// This capability supports dynamic registration.
12 #[serde(skip_serializing_if = "Option::is_none")]
13 pub dynamic_registration: Option<bool>,
14
15 /// Specific capabilities for the `SymbolKind` in the `workspace/symbol` request.
16 #[serde(skip_serializing_if = "Option::is_none")]
17 pub symbol_kind: Option<SymbolKindCapability>,
18
19 /// The client supports tags on `SymbolInformation`.
20 /// Clients supporting tags have to handle unknown tags gracefully.
21 ///
22 /// @since 3.16.0
23 #[serde(
24 default,
25 skip_serializing_if = "Option::is_none",
26 deserialize_with = "TagSupport::deserialize_compat"
27 )]
28 pub tag_support: Option<TagSupport<SymbolTag>>,
29
30 /// The client support partial workspace symbols. The client will send the
31 /// request `workspaceSymbol/resolve` to the server to resolve additional
32 /// properties.
33 ///
34 /// @since 3.17.0
35 #[serde(skip_serializing_if = "Option::is_none")]
36 pub resolve_support: Option<WorkspaceSymbolResolveSupportCapability>,
37}
38
39/// The parameters of a Workspace Symbol Request.
40#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
41pub struct WorkspaceSymbolParams {
42 #[serde(flatten)]
43 pub partial_result_params: PartialResultParams,
44
45 #[serde(flatten)]
46 pub work_done_progress_params: WorkDoneProgressParams,
47
48 /// A non-empty query string
49 pub query: String,
50}
51
52#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
53pub struct WorkspaceSymbolResolveSupportCapability {
54 /// The properties that a client can resolve lazily. Usually
55 /// `location.range`
56 pub properties: Vec<String>,
57}
58
59/// A special workspace symbol that supports locations without a range
60///
61/// @since 3.17.0
62#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
63#[serde(rename_all = "camelCase")]
64pub struct WorkspaceSymbol {
65 /// The name of this symbol.
66 pub name: String,
67
68 /// The kind of this symbol.
69 pub kind: SymbolKind,
70
71 /// Tags for this completion item.
72 #[serde(skip_serializing_if = "Option::is_none")]
73 pub tags: Option<Vec<SymbolTag>>,
74
75 /// The name of the symbol containing this symbol. This information is for
76 /// user interface purposes (e.g. to render a qualifier in the user interface
77 /// if necessary). It can't be used to re-infer a hierarchy for the document
78 /// symbols.
79 #[serde(skip_serializing_if = "Option::is_none")]
80 pub container_name: Option<String>,
81
82 /// The location of this symbol. Whether a server is allowed to
83 /// return a location without a range depends on the client
84 /// capability `workspace.symbol.resolveSupport`.
85 ///
86 /// See also `SymbolInformation.location`.
87 pub location: OneOf<Location, WorkspaceLocation>,
88
89 /// A data entry field that is preserved on a workspace symbol between a
90 /// workspace symbol request and a workspace symbol resolve request.
91 #[serde(skip_serializing_if = "Option::is_none")]
92 pub data: Option<LSPAny>,
93}
94
95#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
96pub struct WorkspaceLocation {
97 pub uri: Url,
98}
99
100#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
101#[serde(untagged)]
102pub enum WorkspaceSymbolResponse {
103 Flat(Vec<SymbolInformation>),
104 Nested(Vec<WorkspaceSymbol>),
105}
106