mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 14:13:58 +00:00
Merge pull request #18717 from Veykril/push-pomxnvxotwlr
internal: Set `result_id` for pull diagnostics
This commit is contained in:
commit
fe027d79d2
1 changed files with 11 additions and 7 deletions
|
@ -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,
|
||||
},
|
||||
),
|
||||
)
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue