1use serde::{Deserialize, Serialize};
2use url::Url;
34use crate::{
5 FullDocumentDiagnosticReport, PartialResultParams, UnchangedDocumentDiagnosticReport,
6 WorkDoneProgressParams,
7};
89/// Workspace client capabilities specific to diagnostic pull requests.
10///
11/// @since 3.17.0
12#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
13#[serde(rename_all = "camelCase")]
14pub struct DiagnosticWorkspaceClientCapabilities {
15/// Whether the client implementation supports a refresh request sent from
16 /// the server to the client.
17 ///
18 /// Note that this event is global and will force the client to refresh all
19 /// pulled diagnostics currently shown. It should be used with absolute care
20 /// and is useful for situation where a server for example detects a project
21 /// wide change that requires such a calculation.
22#[serde(skip_serializing_if = "Option::is_none")]
23pub refresh_support: Option<bool>,
24}
2526/// A previous result ID in a workspace pull request.
27///
28/// @since 3.17.0
29#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
30pub struct PreviousResultId {
31/// The URI for which the client knows a result ID.
32pub uri: Url,
3334/// The value of the previous result ID.
35pub value: String,
36}
3738/// Parameters of the workspace diagnostic request.
39///
40/// @since 3.17.0
41#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
42#[serde(rename_all = "camelCase")]
43pub struct WorkspaceDiagnosticParams {
44/// The additional identifier provided during registration.
45pub identifier: Option<String>,
4647/// The currently known diagnostic reports with their
48 /// previous result ids.
49pub previous_result_ids: Vec<PreviousResultId>,
5051#[serde(flatten)]
52pub work_done_progress_params: WorkDoneProgressParams,
5354#[serde(flatten)]
55pub partial_result_params: PartialResultParams,
56}
5758/// A full document diagnostic report for a workspace diagnostic result.
59///
60/// @since 3.17.0
61#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
62#[serde(rename_all = "camelCase")]
63pub struct WorkspaceFullDocumentDiagnosticReport {
64/// The URI for which diagnostic information is reported.
65pub uri: Url,
6667/// The version number for which the diagnostics are reported.
68 ///
69 /// If the document is not marked as open, `None` can be provided.
70pub version: Option<i64>,
7172#[serde(flatten)]
73pub full_document_diagnostic_report: FullDocumentDiagnosticReport,
74}
7576/// An unchanged document diagnostic report for a workspace diagnostic result.
77///
78/// @since 3.17.0
79#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
80#[serde(rename_all = "camelCase")]
81pub struct WorkspaceUnchangedDocumentDiagnosticReport {
82/// The URI for which diagnostic information is reported.
83pub uri: Url,
8485/// The version number for which the diagnostics are reported.
86 ///
87 /// If the document is not marked as open, `None` can be provided.
88pub version: Option<i64>,
8990#[serde(flatten)]
91pub unchanged_document_diagnostic_report: UnchangedDocumentDiagnosticReport,
92}
9394/// A workspace diagnostic document report.
95///
96/// @since 3.17.0
97#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
98#[serde(tag = "kind", rename_all = "lowercase")]
99pub enum WorkspaceDocumentDiagnosticReport {
100 Full(WorkspaceFullDocumentDiagnosticReport),
101 Unchanged(WorkspaceUnchangedDocumentDiagnosticReport),
102}
103104impl From<WorkspaceFullDocumentDiagnosticReport> for WorkspaceDocumentDiagnosticReport {
105fn from(from: WorkspaceFullDocumentDiagnosticReport) -> Self {
106 WorkspaceDocumentDiagnosticReport::Full(from)
107 }
108}
109110impl From<WorkspaceUnchangedDocumentDiagnosticReport> for WorkspaceDocumentDiagnosticReport {
111fn from(from: WorkspaceUnchangedDocumentDiagnosticReport) -> Self {
112 WorkspaceDocumentDiagnosticReport::Unchanged(from)
113 }
114}
115116/// A workspace diagnostic report.
117///
118/// @since 3.17.0
119#[derive(Debug, PartialEq, Default, Deserialize, Serialize, Clone)]
120pub struct WorkspaceDiagnosticReport {
121pub items: Vec<WorkspaceDocumentDiagnosticReport>,
122}
123124/// A partial result for a workspace diagnostic report.
125///
126/// @since 3.17.0
127#[derive(Debug, PartialEq, Default, Deserialize, Serialize, Clone)]
128pub struct WorkspaceDiagnosticReportPartialResult {
129pub items: Vec<WorkspaceDocumentDiagnosticReport>,
130}
131132#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
133#[serde(untagged)]
134pub enum WorkspaceDiagnosticReportResult {
135 Report(WorkspaceDiagnosticReport),
136 Partial(WorkspaceDiagnosticReportPartialResult),
137}
138139impl From<WorkspaceDiagnosticReport> for WorkspaceDiagnosticReportResult {
140fn from(from: WorkspaceDiagnosticReport) -> Self {
141 WorkspaceDiagnosticReportResult::Report(from)
142 }
143}
144145impl From<WorkspaceDiagnosticReportPartialResult> for WorkspaceDiagnosticReportResult {
146fn from(from: WorkspaceDiagnosticReportPartialResult) -> Self {
147 WorkspaceDiagnosticReportResult::Partial(from)
148 }
149}