1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4use url::Url;
5
6use crate::{
7 Diagnostic, PartialResultParams, StaticRegistrationOptions, TextDocumentIdentifier,
8 TextDocumentRegistrationOptions, WorkDoneProgressOptions, WorkDoneProgressParams,
9};
10
11#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
15#[serde(rename_all = "camelCase")]
16pub struct DiagnosticClientCapabilities {
17 #[serde(skip_serializing_if = "Option::is_none")]
22 pub dynamic_registration: Option<bool>,
23
24 #[serde(skip_serializing_if = "Option::is_none")]
26 pub related_document_support: Option<bool>,
27}
28
29#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
33#[serde(rename_all = "camelCase")]
34pub struct DiagnosticOptions {
35 #[serde(skip_serializing_if = "Option::is_none")]
38 pub identifier: Option<String>,
39
40 pub inter_file_dependencies: bool,
44
45 pub workspace_diagnostics: bool,
47
48 #[serde(flatten)]
49 pub work_done_progress_options: WorkDoneProgressOptions,
50}
51
52#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
56#[serde(rename_all = "camelCase")]
57pub struct DiagnosticRegistrationOptions {
58 #[serde(flatten)]
59 pub text_document_registration_options: TextDocumentRegistrationOptions,
60
61 #[serde(flatten)]
62 pub diagnostic_options: DiagnosticOptions,
63
64 #[serde(flatten)]
65 pub static_registration_options: StaticRegistrationOptions,
66}
67
68#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
69#[serde(untagged)]
70pub enum DiagnosticServerCapabilities {
71 Options(DiagnosticOptions),
72 RegistrationOptions(DiagnosticRegistrationOptions),
73}
74
75#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
79#[serde(rename_all = "camelCase")]
80pub struct DocumentDiagnosticParams {
81 pub text_document: TextDocumentIdentifier,
83
84 pub identifier: Option<String>,
86
87 pub previous_result_id: Option<String>,
89
90 #[serde(flatten)]
91 pub work_done_progress_params: WorkDoneProgressParams,
92
93 #[serde(flatten)]
94 pub partial_result_params: PartialResultParams,
95}
96
97#[derive(Debug, PartialEq, Default, Deserialize, Serialize, Clone)]
101#[serde(rename_all = "camelCase")]
102pub struct FullDocumentDiagnosticReport {
103 #[serde(skip_serializing_if = "Option::is_none")]
106 pub result_id: Option<String>,
107
108 pub items: Vec<Diagnostic>,
110}
111
112#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
118#[serde(rename_all = "camelCase")]
119pub struct UnchangedDocumentDiagnosticReport {
120 pub result_id: String,
122}
123
124#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
128#[serde(tag = "kind", rename_all = "lowercase")]
129pub enum DocumentDiagnosticReportKind {
130 Full(FullDocumentDiagnosticReport),
132 Unchanged(UnchangedDocumentDiagnosticReport),
134}
135
136impl From<FullDocumentDiagnosticReport> for DocumentDiagnosticReportKind {
137 fn from(from: FullDocumentDiagnosticReport) -> Self {
138 DocumentDiagnosticReportKind::Full(from)
139 }
140}
141
142impl From<UnchangedDocumentDiagnosticReport> for DocumentDiagnosticReportKind {
143 fn from(from: UnchangedDocumentDiagnosticReport) -> Self {
144 DocumentDiagnosticReportKind::Unchanged(from)
145 }
146}
147
148#[derive(Debug, PartialEq, Default, Deserialize, Serialize, Clone)]
152#[serde(rename_all = "camelCase")]
153pub struct RelatedFullDocumentDiagnosticReport {
154 #[serde(with = "crate::url_map")]
162 #[serde(skip_serializing_if = "Option::is_none")]
163 #[serde(default)]
164 pub related_documents: Option<HashMap<Url, DocumentDiagnosticReportKind>>,
165 #[serde(flatten)]
167 pub full_document_diagnostic_report: FullDocumentDiagnosticReport,
168}
169
170#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
174#[serde(rename_all = "camelCase")]
175pub struct RelatedUnchangedDocumentDiagnosticReport {
176 #[serde(with = "crate::url_map")]
184 #[serde(skip_serializing_if = "Option::is_none")]
185 #[serde(default)]
186 pub related_documents: Option<HashMap<Url, DocumentDiagnosticReportKind>>,
187 #[serde(flatten)]
189 pub unchanged_document_diagnostic_report: UnchangedDocumentDiagnosticReport,
190}
191
192#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
200#[serde(tag = "kind", rename_all = "lowercase")]
201pub enum DocumentDiagnosticReport {
202 Full(RelatedFullDocumentDiagnosticReport),
204 Unchanged(RelatedUnchangedDocumentDiagnosticReport),
206}
207
208impl From<RelatedFullDocumentDiagnosticReport> for DocumentDiagnosticReport {
209 fn from(from: RelatedFullDocumentDiagnosticReport) -> Self {
210 DocumentDiagnosticReport::Full(from)
211 }
212}
213
214impl From<RelatedUnchangedDocumentDiagnosticReport> for DocumentDiagnosticReport {
215 fn from(from: RelatedUnchangedDocumentDiagnosticReport) -> Self {
216 DocumentDiagnosticReport::Unchanged(from)
217 }
218}
219
220#[derive(Debug, PartialEq, Default, Deserialize, Serialize, Clone)]
224#[serde(rename_all = "camelCase")]
225pub struct DocumentDiagnosticReportPartialResult {
226 #[serde(with = "crate::url_map")]
227 #[serde(skip_serializing_if = "Option::is_none")]
228 #[serde(default)]
229 pub related_documents: Option<HashMap<Url, DocumentDiagnosticReportKind>>,
230 }
232
233#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
234#[serde(untagged)]
235pub enum DocumentDiagnosticReportResult {
236 Report(DocumentDiagnosticReport),
237 Partial(DocumentDiagnosticReportPartialResult),
238}
239
240impl From<DocumentDiagnosticReport> for DocumentDiagnosticReportResult {
241 fn from(from: DocumentDiagnosticReport) -> Self {
242 DocumentDiagnosticReportResult::Report(from)
243 }
244}
245
246impl From<DocumentDiagnosticReportPartialResult> for DocumentDiagnosticReportResult {
247 fn from(from: DocumentDiagnosticReportPartialResult) -> Self {
248 DocumentDiagnosticReportResult::Partial(from)
249 }
250}
251
252#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
258#[serde(rename_all = "camelCase")]
259pub struct DiagnosticServerCancellationData {
260 pub retrigger_request: bool,
261}
262
263impl Default for DiagnosticServerCancellationData {
264 fn default() -> Self {
265 DiagnosticServerCancellationData {
266 retrigger_request: true,
267 }
268 }
269}