Use Handle/Actor terminology for flycheck
This commit is contained in:
parent
659b16981a
commit
69e6924dd5
@ -48,21 +48,21 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|||||||
/// diagnostics based on the output.
|
/// diagnostics based on the output.
|
||||||
/// The spawned thread is shut down when this struct is dropped.
|
/// The spawned thread is shut down when this struct is dropped.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Flycheck {
|
pub struct FlycheckHandle {
|
||||||
// XXX: drop order is significant
|
// XXX: drop order is significant
|
||||||
cmd_send: Sender<CheckCommand>,
|
cmd_send: Sender<CheckCommand>,
|
||||||
handle: jod_thread::JoinHandle<()>,
|
handle: jod_thread::JoinHandle<()>,
|
||||||
pub task_recv: Receiver<CheckTask>,
|
pub task_recv: Receiver<CheckTask>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Flycheck {
|
impl FlycheckHandle {
|
||||||
pub fn new(config: FlycheckConfig, workspace_root: PathBuf) -> Flycheck {
|
pub fn spawn(config: FlycheckConfig, workspace_root: PathBuf) -> FlycheckHandle {
|
||||||
let (task_send, task_recv) = unbounded::<CheckTask>();
|
let (task_send, task_recv) = unbounded::<CheckTask>();
|
||||||
let (cmd_send, cmd_recv) = unbounded::<CheckCommand>();
|
let (cmd_send, cmd_recv) = unbounded::<CheckCommand>();
|
||||||
let handle = jod_thread::spawn(move || {
|
let handle = jod_thread::spawn(move || {
|
||||||
FlycheckThread::new(config, workspace_root).run(&task_send, &cmd_recv);
|
FlycheckActor::new(config, workspace_root).run(&task_send, &cmd_recv);
|
||||||
});
|
});
|
||||||
Flycheck { task_recv, cmd_send, handle }
|
FlycheckHandle { task_recv, cmd_send, handle }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Schedule a re-start of the cargo check worker.
|
/// Schedule a re-start of the cargo check worker.
|
||||||
@ -95,7 +95,7 @@ pub enum CheckCommand {
|
|||||||
Update,
|
Update,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FlycheckThread {
|
struct FlycheckActor {
|
||||||
config: FlycheckConfig,
|
config: FlycheckConfig,
|
||||||
workspace_root: PathBuf,
|
workspace_root: PathBuf,
|
||||||
last_update_req: Option<Instant>,
|
last_update_req: Option<Instant>,
|
||||||
@ -109,9 +109,9 @@ struct FlycheckThread {
|
|||||||
check_process: Option<jod_thread::JoinHandle<()>>,
|
check_process: Option<jod_thread::JoinHandle<()>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FlycheckThread {
|
impl FlycheckActor {
|
||||||
fn new(config: FlycheckConfig, workspace_root: PathBuf) -> FlycheckThread {
|
fn new(config: FlycheckConfig, workspace_root: PathBuf) -> FlycheckActor {
|
||||||
FlycheckThread {
|
FlycheckActor {
|
||||||
config,
|
config,
|
||||||
workspace_root,
|
workspace_root,
|
||||||
last_update_req: None,
|
last_update_req: None,
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
use lsp_types::Url;
|
use lsp_types::Url;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use ra_db::{CrateId, SourceRoot, VfsPath};
|
use ra_db::{CrateId, SourceRoot, VfsPath};
|
||||||
use ra_flycheck::{Flycheck, FlycheckConfig};
|
use ra_flycheck::{FlycheckConfig, FlycheckHandle};
|
||||||
use ra_ide::{Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId};
|
use ra_ide::{Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId};
|
||||||
use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target};
|
use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target};
|
||||||
use stdx::format_to;
|
use stdx::format_to;
|
||||||
@ -27,12 +27,15 @@
|
|||||||
};
|
};
|
||||||
use rustc_hash::{FxHashMap, FxHashSet};
|
use rustc_hash::{FxHashMap, FxHashSet};
|
||||||
|
|
||||||
fn create_flycheck(workspaces: &[ProjectWorkspace], config: &FlycheckConfig) -> Option<Flycheck> {
|
fn create_flycheck(
|
||||||
|
workspaces: &[ProjectWorkspace],
|
||||||
|
config: &FlycheckConfig,
|
||||||
|
) -> Option<FlycheckHandle> {
|
||||||
// FIXME: Figure out the multi-workspace situation
|
// FIXME: Figure out the multi-workspace situation
|
||||||
workspaces.iter().find_map(move |w| match w {
|
workspaces.iter().find_map(move |w| match w {
|
||||||
ProjectWorkspace::Cargo { cargo, .. } => {
|
ProjectWorkspace::Cargo { cargo, .. } => {
|
||||||
let cargo_project_root = cargo.workspace_root().to_path_buf();
|
let cargo_project_root = cargo.workspace_root().to_path_buf();
|
||||||
Some(Flycheck::new(config.clone(), cargo_project_root.into()))
|
Some(FlycheckHandle::spawn(config.clone(), cargo_project_root.into()))
|
||||||
}
|
}
|
||||||
ProjectWorkspace::Json { .. } => {
|
ProjectWorkspace::Json { .. } => {
|
||||||
log::warn!("Cargo check watching only supported for cargo workspaces, disabling");
|
log::warn!("Cargo check watching only supported for cargo workspaces, disabling");
|
||||||
@ -63,7 +66,7 @@ pub(crate) struct GlobalState {
|
|||||||
pub(crate) analysis_host: AnalysisHost,
|
pub(crate) analysis_host: AnalysisHost,
|
||||||
pub(crate) loader: Box<dyn vfs::loader::Handle>,
|
pub(crate) loader: Box<dyn vfs::loader::Handle>,
|
||||||
pub(crate) task_receiver: Receiver<vfs::loader::Message>,
|
pub(crate) task_receiver: Receiver<vfs::loader::Message>,
|
||||||
pub(crate) flycheck: Option<Flycheck>,
|
pub(crate) flycheck: Option<FlycheckHandle>,
|
||||||
pub(crate) diagnostics: DiagnosticCollection,
|
pub(crate) diagnostics: DiagnosticCollection,
|
||||||
pub(crate) mem_docs: FxHashSet<VfsPath>,
|
pub(crate) mem_docs: FxHashSet<VfsPath>,
|
||||||
pub(crate) vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>,
|
pub(crate) vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>,
|
||||||
|
Loading…
Reference in New Issue
Block a user