mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Report flycheck errors via status
This commit is contained in:
parent
a2b59b110f
commit
f876adf617
5 changed files with 16 additions and 13 deletions
|
@ -734,7 +734,6 @@ impl fmt::Display for ConfigError {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"invalid config value{}:\n{}",
|
"invalid config value{}:\n{}",
|
||||||
self.errors.len(),
|
|
||||||
if self.errors.len() == 1 { "" } else { "s" },
|
if self.errors.len() == 1 { "" } else { "s" },
|
||||||
errors
|
errors
|
||||||
)
|
)
|
||||||
|
|
|
@ -75,6 +75,7 @@ pub(crate) struct GlobalState {
|
||||||
pub(crate) flycheck: Arc<[FlycheckHandle]>,
|
pub(crate) flycheck: Arc<[FlycheckHandle]>,
|
||||||
pub(crate) flycheck_sender: Sender<flycheck::Message>,
|
pub(crate) flycheck_sender: Sender<flycheck::Message>,
|
||||||
pub(crate) flycheck_receiver: Receiver<flycheck::Message>,
|
pub(crate) flycheck_receiver: Receiver<flycheck::Message>,
|
||||||
|
pub(crate) last_flycheck_error: Option<String>,
|
||||||
|
|
||||||
// VFS
|
// VFS
|
||||||
pub(crate) loader: Handle<Box<dyn vfs::loader::Handle>, Receiver<vfs::loader::Message>>,
|
pub(crate) loader: Handle<Box<dyn vfs::loader::Handle>, Receiver<vfs::loader::Message>>,
|
||||||
|
@ -179,6 +180,7 @@ impl GlobalState {
|
||||||
flycheck: Arc::from(Vec::new()),
|
flycheck: Arc::from(Vec::new()),
|
||||||
flycheck_sender,
|
flycheck_sender,
|
||||||
flycheck_receiver,
|
flycheck_receiver,
|
||||||
|
last_flycheck_error: None,
|
||||||
|
|
||||||
vfs: Arc::new(RwLock::new((vfs::Vfs::default(), IntMap::default()))),
|
vfs: Arc::new(RwLock::new((vfs::Vfs::default(), IntMap::default()))),
|
||||||
vfs_config_version: 0,
|
vfs_config_version: 0,
|
||||||
|
|
|
@ -169,7 +169,7 @@ pub(crate) fn handle_did_change_configuration(
|
||||||
// Note that json can be null according to the spec if the client can't
|
// Note that json can be null according to the spec if the client can't
|
||||||
// provide a configuration. This is handled in Config::update below.
|
// provide a configuration. This is handled in Config::update below.
|
||||||
let mut config = Config::clone(&*this.config);
|
let mut config = Config::clone(&*this.config);
|
||||||
config.update(json.take());
|
this.config_errors = config.update(json.take()).err();
|
||||||
this.update_configuration(config);
|
this.update_configuration(config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -602,21 +602,18 @@ impl GlobalState {
|
||||||
(Progress::Begin, None)
|
(Progress::Begin, None)
|
||||||
}
|
}
|
||||||
flycheck::Progress::DidCheckCrate(target) => (Progress::Report, Some(target)),
|
flycheck::Progress::DidCheckCrate(target) => (Progress::Report, Some(target)),
|
||||||
flycheck::Progress::DidCancel => (Progress::End, None),
|
flycheck::Progress::DidCancel => {
|
||||||
|
self.last_flycheck_error = None;
|
||||||
|
(Progress::End, None)
|
||||||
|
}
|
||||||
flycheck::Progress::DidFailToRestart(err) => {
|
flycheck::Progress::DidFailToRestart(err) => {
|
||||||
self.show_and_log_error(
|
self.last_flycheck_error =
|
||||||
"cargo check failed to start".to_string(),
|
Some(format!("cargo check failed to start: {err}"));
|
||||||
Some(err),
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
flycheck::Progress::DidFinish(result) => {
|
flycheck::Progress::DidFinish(result) => {
|
||||||
if let Err(err) = result {
|
self.last_flycheck_error =
|
||||||
self.show_and_log_error(
|
result.err().map(|err| format!("cargo check failed to start: {err}"));
|
||||||
"cargo check failed".to_string(),
|
|
||||||
Some(err.to_string()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
(Progress::End, None)
|
(Progress::End, None)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -139,6 +139,11 @@ impl GlobalState {
|
||||||
status.health = lsp_ext::Health::Warning;
|
status.health = lsp_ext::Health::Warning;
|
||||||
format_to!(message, "{err}\n");
|
format_to!(message, "{err}\n");
|
||||||
}
|
}
|
||||||
|
if let Some(err) = &self.last_flycheck_error {
|
||||||
|
status.health = lsp_ext::Health::Warning;
|
||||||
|
message.push_str(err);
|
||||||
|
message.push('\n');
|
||||||
|
}
|
||||||
|
|
||||||
for ws in self.workspaces.iter() {
|
for ws in self.workspaces.iter() {
|
||||||
let (ProjectWorkspace::Cargo { sysroot, .. }
|
let (ProjectWorkspace::Cargo { sysroot, .. }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue