| 1 |
use crate::{ |
| 2 |
Location, PartialResultParams, Range, SymbolKind, SymbolKindCapability, TextDocumentIdentifier, |
| 3 |
WorkDoneProgressParams, |
| 4 |
}; |
| 5 |
|
| 6 |
use crate::{SymbolTag, TagSupport}; |
| 7 |
|
| 8 |
use serde::{Deserialize, Serialize}; |
| 9 |
|
| 10 |
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)] |
| 11 |
#[serde(rename_all = "camelCase")] |
| 12 |
pub struct DocumentSymbolClientCapabilities { |
| 13 |
|
| 14 |
#[serde(skip_serializing_if = "Option::is_none")] |
| 15 |
pub dynamic_registration: Option<bool>, |
| 16 |
|
| 17 |
|
| 18 |
#[serde(skip_serializing_if = "Option::is_none")] |
| 19 |
pub symbol_kind: Option<SymbolKindCapability>, |
| 20 |
|
| 21 |
|
| 22 |
#[serde(skip_serializing_if = "Option::is_none")] |
| 23 |
pub hierarchical_document_symbol_support: Option<bool>, |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
#[serde( |
| 31 |
default, |
| 32 |
skip_serializing_if = "Option::is_none", |
| 33 |
deserialize_with = "TagSupport::deserialize_compat" |
| 34 |
)] |
| 35 |
pub tag_support: Option<TagSupport<SymbolTag>>, |
| 36 |
} |
| 37 |
|
| 38 |
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] |
| 39 |
#[serde(untagged)] |
| 40 |
pub enum DocumentSymbolResponse { |
| 41 |
Flat(Vec<SymbolInformation>), |
| 42 |
Nested(Vec<DocumentSymbol>), |
| 43 |
} |
| 44 |
|
| 45 |
impl From<Vec<SymbolInformation>> for DocumentSymbolResponse { |
| 46 |
fn from(info: Vec<SymbolInformation>) -> Self { |
| 47 |
DocumentSymbolResponse::Flat(info) |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
impl From<Vec<DocumentSymbol>> for DocumentSymbolResponse { |
| 52 |
fn from(symbols: Vec<DocumentSymbol>) -> Self { |
| 53 |
DocumentSymbolResponse::Nested(symbols) |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] |
| 58 |
#[serde(rename_all = "camelCase")] |
| 59 |
pub struct DocumentSymbolParams { |
| 60 |
|
| 61 |
pub text_document: TextDocumentIdentifier, |
| 62 |
|
| 63 |
#[serde(flatten)] |
| 64 |
pub work_done_progress_params: WorkDoneProgressParams, |
| 65 |
|
| 66 |
#[serde(flatten)] |
| 67 |
pub partial_result_params: PartialResultParams, |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] |
| 75 |
#[serde(rename_all = "camelCase")] |
| 76 |
pub struct DocumentSymbol { |
| 77 |
|
| 78 |
pub name: String, |
| 79 |
|
| 80 |
|
| 81 |
#[serde(skip_serializing_if = "Option::is_none")] |
| 82 |
pub detail: Option<String>, |
| 83 |
|
| 84 |
pub kind: SymbolKind, |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
#[serde(skip_serializing_if = "Option::is_none")] |
| 89 |
pub tags: Option<Vec<SymbolTag>>, |
| 90 |
|
| 91 |
#[serde(skip_serializing_if = "Option::is_none")] |
| 92 |
#[deprecated(note = "Use tags instead")] |
| 93 |
pub deprecated: Option<bool>, |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
pub range: Range, |
| 98 |
|
| 99 |
|
| 100 |
pub selection_range: Range, |
| 101 |
|
| 102 |
#[serde(skip_serializing_if = "Option::is_none")] |
| 103 |
pub children: Option<Vec<DocumentSymbol>>, |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] |
| 109 |
#[serde(rename_all = "camelCase")] |
| 110 |
pub struct SymbolInformation { |
| 111 |
|
| 112 |
pub name: String, |
| 113 |
|
| 114 |
|
| 115 |
pub kind: SymbolKind, |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
#[serde(skip_serializing_if = "Option::is_none")] |
| 121 |
pub tags: Option<Vec<SymbolTag>>, |
| 122 |
|
| 123 |
|
| 124 |
#[serde(skip_serializing_if = "Option::is_none")] |
| 125 |
#[deprecated(note = "Use tags instead")] |
| 126 |
pub deprecated: Option<bool>, |
| 127 |
|
| 128 |
|
| 129 |
pub location: Location, |
| 130 |
|
| 131 |
|
| 132 |
#[serde(skip_serializing_if = "Option::is_none")] |
| 133 |
pub container_name: Option<String>, |
| 134 |
} |