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