feat(lsp): add support for lsp Diagnostic{}.data (#4935)

This commit is contained in:
sigmaSd 2022-12-02 02:18:45 +01:00 committed by GitHub
parent 8291654326
commit 4960c41f18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 8 deletions

View File

@ -45,4 +45,5 @@ pub struct Diagnostic {
pub code: Option<NumberOrString>, pub code: Option<NumberOrString>,
pub tags: Vec<DiagnosticTag>, pub tags: Vec<DiagnosticTag>,
pub source: Option<String>, pub source: Option<String>,
pub data: Option<serde_json::Value>,
} }

View File

@ -102,16 +102,17 @@ pub fn diagnostic_to_lsp_diagnostic(
None None
}; };
// TODO: add support for Diagnostic.data lsp::Diagnostic {
lsp::Diagnostic::new( range: range_to_lsp_range(doc, range, offset_encoding),
range_to_lsp_range(doc, range, offset_encoding),
severity, severity,
code, code,
diag.source.clone(), source: diag.source.clone(),
diag.message.to_owned(), message: diag.message.to_owned(),
None, related_information: None,
tags, tags,
) data: diag.data.to_owned(),
..Default::default()
}
} }
/// Converts [`lsp::Position`] to a position in the document. /// Converts [`lsp::Position`] to a position in the document.

View File

@ -772,7 +772,8 @@ pub async fn handle_language_server_message(
severity, severity,
code, code,
tags, tags,
source: diagnostic.source.clone() source: diagnostic.source.clone(),
data: diagnostic.data.clone(),
}) })
}) })
.collect(); .collect();