pub fn lsp_diagnostics_to_diagnostics(
document: &Document,
diagnostics: &[LspDiagnostic],
) -> Vec<Diagnostic>Expand description
Converts current-version LSP diagnostics into local diagnostics.
Stale versions are discarded. Endpoints clamp numerically to document byte
length without UTF-8 boundary repair; empty or reversed results are removed.
Remaining inputs preserve order and become crate::DiagnosticSource::Lsp.
ยงExamples
use ailloli_ui_editor::{code::lsp_diagnostics_to_diagnostics, DiagnosticSeverity, Document, DocumentId, DocumentVersion, LspDiagnostic};
use ailloli_ui_text::TextBuffer;
let document = Document::new(DocumentId(1), TextBuffer::from_string("abc"));
let diagnostics = [
LspDiagnostic { range: 1..99, severity: DiagnosticSeverity::Error, message: "bad".into(), document_version: DocumentVersion(0) },
LspDiagnostic { range: 0..1, severity: DiagnosticSeverity::Hint, message: "stale".into(), document_version: DocumentVersion(1) },
];
let mapped = lsp_diagnostics_to_diagnostics(&document, &diagnostics);
assert_eq!(mapped.len(), 1);
assert_eq!(mapped[0].range, 1..3);