Skip to content

Commit

Permalink
Merge pull request #18717 from Veykril/push-pomxnvxotwlr
Browse files Browse the repository at this point in the history
internal: Set `result_id` for pull diagnostics
  • Loading branch information
Veykril authored Dec 19, 2024
2 parents 4aa34ab + 1930075 commit 4f03dd9
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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, &params.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();
Expand Down Expand Up @@ -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(|| {
Expand All @@ -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,
},
),
)
})
Expand Down

0 comments on commit 4f03dd9

Please sign in to comment.