diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2024-12-18 15:14:23 +0100 |
|---|---|---|
| committer | Lukas Wirth <lukastw97@gmail.com> | 2024-12-19 16:24:18 +0100 |
| commit | 1930075c2686af18d2ac9a1df5b780c3aa9544c7 (patch) | |
| tree | 2813b559a587df4619a6d527bfacfc583ab3c865 | |
| parent | 88be63a95bcb8e00c5334aa430d74521f231c1ec (diff) | |
| download | rust-1930075c2686af18d2ac9a1df5b780c3aa9544c7.tar.gz rust-1930075c2686af18d2ac9a1df5b780c3aa9544c7.zip | |
internal: Set `result_id` for pull diagnostics
| -rw-r--r-- | src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs index fa78be5cb60..277d3db5293 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs @@ -481,27 +481,28 @@ pub(crate) fn handle_document_diagnostics( snap: GlobalStateSnapshot, params: lsp_types::DocumentDiagnosticParams, ) -> anyhow::Result<lsp_types::DocumentDiagnosticReportResult> { - const EMPTY: lsp_types::DocumentDiagnosticReportResult = + let empty = || { lsp_types::DocumentDiagnosticReportResult::Report( lsp_types::DocumentDiagnosticReport::Full( lsp_types::RelatedFullDocumentDiagnosticReport { related_documents: None, full_document_diagnostic_report: lsp_types::FullDocumentDiagnosticReport { - result_id: None, + result_id: Some("rust-analyzer".to_owned()), items: vec![], }, }, ), - ); + ) + }; let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?; let source_root = snap.analysis.source_root_id(file_id)?; if !snap.analysis.is_local_source_root(source_root)? { - return Ok(EMPTY); + return Ok(empty()); } let config = snap.config.diagnostics(Some(source_root)); if !config.enabled { - return Ok(EMPTY); + return Ok(empty()); } let line_index = snap.file_line_index(file_id)?; let supports_related = snap.config.text_document_diagnostic_related_document_support(); @@ -529,7 +530,7 @@ pub(crate) fn handle_document_diagnostics( Ok(lsp_types::DocumentDiagnosticReportResult::Report( lsp_types::DocumentDiagnosticReport::Full(lsp_types::RelatedFullDocumentDiagnosticReport { full_document_diagnostic_report: lsp_types::FullDocumentDiagnosticReport { - result_id: None, + result_id: Some("rust-analyzer".to_owned()), items: diagnostics.collect(), }, related_documents: related_documents.is_empty().not().then(|| { @@ -539,7 +540,10 @@ pub(crate) fn handle_document_diagnostics( ( to_proto::url(&snap, id), lsp_types::DocumentDiagnosticReportKind::Full( - lsp_types::FullDocumentDiagnosticReport { result_id: None, items }, + lsp_types::FullDocumentDiagnosticReport { + result_id: Some("rust-analyzer".to_owned()), + items, + }, ), ) }) |
