mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 13:33:31 +00:00
Don't compute diagnostics for non local files
This commit is contained in:
parent
8b59541237
commit
eac7840810
3 changed files with 16 additions and 10 deletions
|
@ -121,8 +121,8 @@ impl RequestDispatcher<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Dispatches a non-latency-sensitive request onto the thread pool. When the VFS is marked not
|
/// Dispatches a non-latency-sensitive request onto the thread pool. When the VFS is marked not
|
||||||
/// ready this will return a default constructed [`R::Result`].
|
/// ready this will return a `default` constructed [`R::Result`].
|
||||||
pub(crate) fn on_or<const ALLOW_RETRYING: bool, R>(
|
pub(crate) fn on_with<const ALLOW_RETRYING: bool, R>(
|
||||||
&mut self,
|
&mut self,
|
||||||
f: fn(GlobalStateSnapshot, R::Params) -> anyhow::Result<R::Result>,
|
f: fn(GlobalStateSnapshot, R::Params) -> anyhow::Result<R::Result>,
|
||||||
default: impl FnOnce() -> R::Result,
|
default: impl FnOnce() -> R::Result,
|
||||||
|
|
|
@ -479,12 +479,8 @@ pub(crate) fn handle_document_diagnostics(
|
||||||
snap: GlobalStateSnapshot,
|
snap: GlobalStateSnapshot,
|
||||||
params: lsp_types::DocumentDiagnosticParams,
|
params: lsp_types::DocumentDiagnosticParams,
|
||||||
) -> anyhow::Result<lsp_types::DocumentDiagnosticReportResult> {
|
) -> anyhow::Result<lsp_types::DocumentDiagnosticReportResult> {
|
||||||
let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?;
|
const EMPTY: lsp_types::DocumentDiagnosticReportResult =
|
||||||
let source_root = snap.analysis.source_root_id(file_id)?;
|
lsp_types::DocumentDiagnosticReportResult::Report(
|
||||||
let line_index = snap.file_line_index(file_id)?;
|
|
||||||
let config = snap.config.diagnostics(Some(source_root));
|
|
||||||
if !config.enabled {
|
|
||||||
return Ok(lsp_types::DocumentDiagnosticReportResult::Report(
|
|
||||||
lsp_types::DocumentDiagnosticReport::Full(
|
lsp_types::DocumentDiagnosticReport::Full(
|
||||||
lsp_types::RelatedFullDocumentDiagnosticReport {
|
lsp_types::RelatedFullDocumentDiagnosticReport {
|
||||||
related_documents: None,
|
related_documents: None,
|
||||||
|
@ -494,8 +490,18 @@ pub(crate) fn handle_document_diagnostics(
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
));
|
);
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
let config = snap.config.diagnostics(Some(source_root));
|
||||||
|
if !config.enabled {
|
||||||
|
return Ok(EMPTY);
|
||||||
|
}
|
||||||
|
let line_index = snap.file_line_index(file_id)?;
|
||||||
let supports_related = snap.config.text_document_diagnostic_related_document_support();
|
let supports_related = snap.config.text_document_diagnostic_related_document_support();
|
||||||
|
|
||||||
let mut related_documents = FxHashMap::default();
|
let mut related_documents = FxHashMap::default();
|
||||||
|
|
|
@ -1092,7 +1092,7 @@ impl GlobalState {
|
||||||
.on_latency_sensitive::<NO_RETRY, lsp_request::SemanticTokensRangeRequest>(handlers::handle_semantic_tokens_range)
|
.on_latency_sensitive::<NO_RETRY, lsp_request::SemanticTokensRangeRequest>(handlers::handle_semantic_tokens_range)
|
||||||
// FIXME: Some of these NO_RETRY could be retries if the file they are interested didn't change.
|
// FIXME: Some of these NO_RETRY could be retries if the file they are interested didn't change.
|
||||||
// All other request handlers
|
// All other request handlers
|
||||||
.on_or::<NO_RETRY, lsp_request::DocumentDiagnosticRequest>(handlers::handle_document_diagnostics, || lsp_types::DocumentDiagnosticReportResult::Report(
|
.on_with::<NO_RETRY, lsp_request::DocumentDiagnosticRequest>(handlers::handle_document_diagnostics, || lsp_types::DocumentDiagnosticReportResult::Report(
|
||||||
lsp_types::DocumentDiagnosticReport::Full(
|
lsp_types::DocumentDiagnosticReport::Full(
|
||||||
lsp_types::RelatedFullDocumentDiagnosticReport {
|
lsp_types::RelatedFullDocumentDiagnosticReport {
|
||||||
related_documents: None,
|
related_documents: None,
|
||||||
|
|
Loading…
Reference in a new issue