mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 23:25:03 +00:00
Set server status to warning when proc-macro sources change
This commit is contained in:
parent
bed6eae304
commit
1d80302b76
3 changed files with 18 additions and 2 deletions
|
@ -8,7 +8,7 @@ use std::{sync::Arc, time::Instant};
|
|||
use crossbeam_channel::{unbounded, Receiver, Sender};
|
||||
use flycheck::FlycheckHandle;
|
||||
use ide::{Analysis, AnalysisHost, Cancellable, Change, FileId};
|
||||
use ide_db::base_db::CrateId;
|
||||
use ide_db::base_db::{CrateId, FileLoader, SourceDatabase};
|
||||
use lsp_types::{SemanticTokens, Url};
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use proc_macro_api::ProcMacroServer;
|
||||
|
@ -58,6 +58,7 @@ pub(crate) struct GlobalState {
|
|||
pub(crate) mem_docs: MemDocs,
|
||||
pub(crate) semantic_tokens_cache: Arc<Mutex<FxHashMap<Url, SemanticTokens>>>,
|
||||
pub(crate) shutdown_requested: bool,
|
||||
pub(crate) proc_macro_changed: bool,
|
||||
pub(crate) last_reported_status: Option<lsp_ext::ServerStatusParams>,
|
||||
pub(crate) source_root_config: SourceRootConfig,
|
||||
pub(crate) proc_macro_client: Option<ProcMacroServer>,
|
||||
|
@ -147,6 +148,7 @@ impl GlobalState {
|
|||
mem_docs: MemDocs::default(),
|
||||
semantic_tokens_cache: Arc::new(Default::default()),
|
||||
shutdown_requested: false,
|
||||
proc_macro_changed: false,
|
||||
last_reported_status: None,
|
||||
source_root_config: SourceRootConfig::default(),
|
||||
proc_macro_client: None,
|
||||
|
@ -187,6 +189,15 @@ impl GlobalState {
|
|||
}
|
||||
|
||||
for file in changed_files {
|
||||
if !file.is_created_or_deleted() {
|
||||
let crates = self.analysis_host.raw_database().relevant_crates(file.file_id);
|
||||
let crate_graph = self.analysis_host.raw_database().crate_graph();
|
||||
|
||||
if crates.iter().any(|&krate| !crate_graph[krate].proc_macro.is_empty()) {
|
||||
self.proc_macro_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(path) = vfs.file_path(file.file_id).as_path() {
|
||||
let path = path.to_path_buf();
|
||||
if reload::should_refresh_for_change(&path, file.change_kind) {
|
||||
|
|
|
@ -561,7 +561,7 @@ impl GlobalState {
|
|||
s.shutdown_requested = true;
|
||||
Ok(())
|
||||
})?
|
||||
.on_sync_mut::<lsp_ext::MemoryUsage>(|s, p| handlers::handle_memory_usage(s, p))?
|
||||
.on_sync_mut::<lsp_ext::MemoryUsage>(handlers::handle_memory_usage)?
|
||||
.on_sync::<lsp_ext::JoinLines>(handlers::handle_join_lines)?
|
||||
.on_sync::<lsp_ext::OnEnter>(handlers::handle_on_enter)?
|
||||
.on_sync::<lsp_types::request::SelectionRangeRequest>(handlers::handle_selection_range)?
|
||||
|
|
|
@ -66,6 +66,11 @@ impl GlobalState {
|
|||
message: None,
|
||||
};
|
||||
|
||||
if self.proc_macro_changed {
|
||||
status.health = lsp_ext::Health::Warning;
|
||||
status.message =
|
||||
Some("Reload required due to source changes of a procedural macro.".into())
|
||||
}
|
||||
if let Some(error) = self.fetch_build_data_error() {
|
||||
status.health = lsp_ext::Health::Warning;
|
||||
status.message = Some(error)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue