1use crate::{
2 Location, PartialResultParams, Range, SymbolKind, SymbolKindCapability, TextDocumentIdentifier,
3 WorkDoneProgressParams,
4};
56use crate::{SymbolTag, TagSupport};
78use serde::{Deserialize, Serialize};
910#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
11#[serde(rename_all = "camelCase")]
12pub struct DocumentSymbolClientCapabilities {
13/// This capability supports dynamic registration.
14#[serde(skip_serializing_if = "Option::is_none")]
15pub dynamic_registration: Option<bool>,
1617/// Specific capabilities for the `SymbolKind`.
18#[serde(skip_serializing_if = "Option::is_none")]
19pub symbol_kind: Option<SymbolKindCapability>,
2021/// The client support hierarchical document symbols.
22#[serde(skip_serializing_if = "Option::is_none")]
23pub hierarchical_document_symbol_support: Option<bool>,
2425/// The client supports tags on `SymbolInformation`. Tags are supported on
26 /// `DocumentSymbol` if `hierarchicalDocumentSymbolSupport` is set to true.
27 /// Clients supporting tags have to handle unknown tags gracefully.
28 ///
29 /// @since 3.16.0
30#[serde(
31 default,
32 skip_serializing_if = "Option::is_none",
33 deserialize_with = "TagSupport::deserialize_compat"
34)]
35pub tag_support: Option<TagSupport<SymbolTag>>,
36}
3738#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum DocumentSymbolResponse {
41 Flat(Vec<SymbolInformation>),
42 Nested(Vec<DocumentSymbol>),
43}
4445impl From<Vec<SymbolInformation>> for DocumentSymbolResponse {
46fn from(info: Vec<SymbolInformation>) -> Self {
47 DocumentSymbolResponse::Flat(info)
48 }
49}
5051impl From<Vec<DocumentSymbol>> for DocumentSymbolResponse {
52fn from(symbols: Vec<DocumentSymbol>) -> Self {
53 DocumentSymbolResponse::Nested(symbols)
54 }
55}
5657#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
58#[serde(rename_all = "camelCase")]
59pub struct DocumentSymbolParams {
60/// The text document.
61pub text_document: TextDocumentIdentifier,
6263#[serde(flatten)]
64pub work_done_progress_params: WorkDoneProgressParams,
6566#[serde(flatten)]
67pub partial_result_params: PartialResultParams,
68}
6970/// Represents programming constructs like variables, classes, interfaces etc.
71/// that appear in a document. Document symbols can be hierarchical and they have two ranges:
72/// one that encloses its definition and one that points to its most interesting range,
73/// e.g. the range of an identifier.
74#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
75#[serde(rename_all = "camelCase")]
76pub struct DocumentSymbol {
77/// The name of this symbol.
78pub name: String,
79/// More detail for this symbol, e.g the signature of a function. If not provided the
80 /// name is used.
81#[serde(skip_serializing_if = "Option::is_none")]
82pub detail: Option<String>,
83/// The kind of this symbol.
84pub kind: SymbolKind,
85/// Tags for this completion item.
86 ///
87 /// @since 3.15.0
88#[serde(skip_serializing_if = "Option::is_none")]
89pub tags: Option<Vec<SymbolTag>>,
90/// Indicates if this symbol is deprecated.
91#[serde(skip_serializing_if = "Option::is_none")]
92 #[deprecated(note = "Use tags instead")]
93pub deprecated: Option<bool>,
94/// The range enclosing this symbol not including leading/trailing whitespace but everything else
95 /// like comments. This information is typically used to determine if the the clients cursor is
96 /// inside the symbol to reveal in the symbol in the UI.
97pub range: Range,
98/// The range that should be selected and revealed when this symbol is being picked, e.g the name of a function.
99 /// Must be contained by the the `range`.
100pub selection_range: Range,
101/// Children of this symbol, e.g. properties of a class.
102#[serde(skip_serializing_if = "Option::is_none")]
103pub children: Option<Vec<DocumentSymbol>>,
104}
105106/// Represents information about programming constructs like variables, classes,
107/// interfaces etc.
108#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
109#[serde(rename_all = "camelCase")]
110pub struct SymbolInformation {
111/// The name of this symbol.
112pub name: String,
113114/// The kind of this symbol.
115pub kind: SymbolKind,
116117/// Tags for this completion item.
118 ///
119 /// @since 3.16.0
120#[serde(skip_serializing_if = "Option::is_none")]
121pub tags: Option<Vec<SymbolTag>>,
122123/// Indicates if this symbol is deprecated.
124#[serde(skip_serializing_if = "Option::is_none")]
125 #[deprecated(note = "Use tags instead")]
126pub deprecated: Option<bool>,
127128/// The location of this symbol.
129pub location: Location,
130131/// The name of the symbol containing this symbol.
132#[serde(skip_serializing_if = "Option::is_none")]
133pub container_name: Option<String>,
134}