mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
parent
6f3c8dc11d
commit
a40e05dd5d
3 changed files with 25 additions and 22 deletions
|
@ -63,7 +63,9 @@ pub(crate) struct GlobalState {
|
|||
req_queue: ReqQueue,
|
||||
pub(crate) task_pool: Handle<TaskPool<Task>, Receiver<Task>>,
|
||||
pub(crate) loader: Handle<Box<dyn vfs::loader::Handle>, Receiver<vfs::loader::Message>>,
|
||||
pub(crate) flycheck: Option<Handle<FlycheckHandle, Receiver<flycheck::Message>>>,
|
||||
pub(crate) flycheck: Option<FlycheckHandle>,
|
||||
pub(crate) flycheck_sender: Sender<flycheck::Message>,
|
||||
pub(crate) flycheck_receiver: Receiver<flycheck::Message>,
|
||||
pub(crate) config: Config,
|
||||
pub(crate) analysis_host: AnalysisHost,
|
||||
pub(crate) diagnostics: DiagnosticCollection,
|
||||
|
@ -103,12 +105,15 @@ impl GlobalState {
|
|||
};
|
||||
|
||||
let analysis_host = AnalysisHost::new(config.lru_capacity);
|
||||
let (flycheck_sender, flycheck_receiver) = unbounded();
|
||||
GlobalState {
|
||||
sender,
|
||||
req_queue: ReqQueue::default(),
|
||||
task_pool,
|
||||
loader,
|
||||
flycheck: None,
|
||||
flycheck_sender,
|
||||
flycheck_receiver,
|
||||
config,
|
||||
analysis_host,
|
||||
diagnostics: Default::default(),
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::{
|
|||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use crossbeam_channel::{never, select, Receiver};
|
||||
use crossbeam_channel::{select, Receiver};
|
||||
use lsp_server::{Connection, Notification, Request, Response};
|
||||
use lsp_types::notification::Notification as _;
|
||||
use ra_db::VfsPath;
|
||||
|
@ -108,7 +108,7 @@ impl GlobalState {
|
|||
recv(self.loader.receiver) -> task =>
|
||||
Some(Event::Vfs(task.unwrap())),
|
||||
|
||||
recv(self.flycheck.as_ref().map_or(&never(), |it| &it.receiver)) -> task =>
|
||||
recv(self.flycheck_receiver) -> task =>
|
||||
Some(Event::Flycheck(task.unwrap())),
|
||||
}
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ impl GlobalState {
|
|||
let state_changed = self.process_changes();
|
||||
if prev_status == Status::Loading && self.status == Status::Ready {
|
||||
if let Some(flycheck) = &self.flycheck {
|
||||
flycheck.handle.update();
|
||||
flycheck.update();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -441,7 +441,7 @@ impl GlobalState {
|
|||
})?
|
||||
.on::<lsp_types::notification::DidSaveTextDocument>(|this, params| {
|
||||
if let Some(flycheck) = &this.flycheck {
|
||||
flycheck.handle.update();
|
||||
flycheck.update();
|
||||
}
|
||||
if let Ok(abs_path) = from_proto::abs_path(¶ms.text_document.uri) {
|
||||
this.maybe_refresh(&[(abs_path, ChangeKind::Modify)]);
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
//! Project loading & configuration updates
|
||||
use std::{mem, sync::Arc};
|
||||
|
||||
use crossbeam_channel::unbounded;
|
||||
use flycheck::FlycheckHandle;
|
||||
use ra_db::{CrateGraph, SourceRoot, VfsPath};
|
||||
use ra_ide::AnalysisChange;
|
||||
use ra_prof::profile;
|
||||
use ra_project_model::{PackageRoot, ProcMacroClient, ProjectWorkspace};
|
||||
use vfs::{file_set::FileSetConfig, AbsPath, AbsPathBuf, ChangeKind};
|
||||
|
||||
use crate::{
|
||||
config::{Config, FilesWatcher, LinkedProject},
|
||||
global_state::{GlobalState, Handle, Status},
|
||||
global_state::{GlobalState, Status},
|
||||
lsp_ext,
|
||||
main_loop::Task,
|
||||
};
|
||||
use ra_prof::profile;
|
||||
|
||||
impl GlobalState {
|
||||
pub(crate) fn update_configuration(&mut self, config: Config) {
|
||||
|
@ -231,20 +230,19 @@ impl GlobalState {
|
|||
}
|
||||
};
|
||||
|
||||
// FIXME: Figure out the multi-workspace situation
|
||||
self.flycheck = self.workspaces.iter().find_map(move |w| match w {
|
||||
ProjectWorkspace::Cargo { cargo, .. } => {
|
||||
let (sender, receiver) = unbounded();
|
||||
let sender = self.flycheck_sender.clone();
|
||||
let sender = Box::new(move |msg| sender.send(msg).unwrap());
|
||||
self.flycheck = self
|
||||
.workspaces
|
||||
.iter()
|
||||
// FIXME: Figure out the multi-workspace situation
|
||||
.find_map(|w| match w {
|
||||
ProjectWorkspace::Cargo { cargo, sysroot: _ } => Some(cargo),
|
||||
ProjectWorkspace::Json { .. } => None,
|
||||
})
|
||||
.map(move |cargo| {
|
||||
let cargo_project_root = cargo.workspace_root().to_path_buf();
|
||||
let handle =
|
||||
FlycheckHandle::spawn(sender, config.clone(), cargo_project_root.into());
|
||||
Some(Handle { handle, receiver })
|
||||
}
|
||||
ProjectWorkspace::Json { .. } => {
|
||||
log::warn!("Cargo check watching only supported for cargo workspaces, disabling");
|
||||
None
|
||||
}
|
||||
FlycheckHandle::spawn(sender, config.clone(), cargo_project_root.into())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue