diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_flycheck/src/lib.rs | 18 | ||||
-rw-r--r-- | crates/rust-analyzer/src/global_state.rs | 11 |
2 files changed, 16 insertions, 13 deletions
diff --git a/crates/ra_flycheck/src/lib.rs b/crates/ra_flycheck/src/lib.rs index 0e2ee8698..6751e5c38 100644 --- a/crates/ra_flycheck/src/lib.rs +++ b/crates/ra_flycheck/src/lib.rs | |||
@@ -48,21 +48,21 @@ impl fmt::Display for FlycheckConfig { | |||
48 | /// diagnostics based on the output. | 48 | /// diagnostics based on the output. |
49 | /// The spawned thread is shut down when this struct is dropped. | 49 | /// The spawned thread is shut down when this struct is dropped. |
50 | #[derive(Debug)] | 50 | #[derive(Debug)] |
51 | pub struct Flycheck { | 51 | pub struct FlycheckHandle { |
52 | // XXX: drop order is significant | 52 | // XXX: drop order is significant |
53 | cmd_send: Sender<CheckCommand>, | 53 | cmd_send: Sender<CheckCommand>, |
54 | handle: jod_thread::JoinHandle<()>, | 54 | handle: jod_thread::JoinHandle<()>, |
55 | pub task_recv: Receiver<CheckTask>, | 55 | pub task_recv: Receiver<CheckTask>, |
56 | } | 56 | } |
57 | 57 | ||
58 | impl Flycheck { | 58 | impl FlycheckHandle { |
59 | pub fn new(config: FlycheckConfig, workspace_root: PathBuf) -> Flycheck { | 59 | pub fn spawn(config: FlycheckConfig, workspace_root: PathBuf) -> FlycheckHandle { |
60 | let (task_send, task_recv) = unbounded::<CheckTask>(); | 60 | let (task_send, task_recv) = unbounded::<CheckTask>(); |
61 | let (cmd_send, cmd_recv) = unbounded::<CheckCommand>(); | 61 | let (cmd_send, cmd_recv) = unbounded::<CheckCommand>(); |
62 | let handle = jod_thread::spawn(move || { | 62 | let handle = jod_thread::spawn(move || { |
63 | FlycheckThread::new(config, workspace_root).run(&task_send, &cmd_recv); | 63 | FlycheckActor::new(config, workspace_root).run(&task_send, &cmd_recv); |
64 | }); | 64 | }); |
65 | Flycheck { task_recv, cmd_send, handle } | 65 | FlycheckHandle { task_recv, cmd_send, handle } |
66 | } | 66 | } |
67 | 67 | ||
68 | /// Schedule a re-start of the cargo check worker. | 68 | /// Schedule a re-start of the cargo check worker. |
@@ -95,7 +95,7 @@ pub enum CheckCommand { | |||
95 | Update, | 95 | Update, |
96 | } | 96 | } |
97 | 97 | ||
98 | struct FlycheckThread { | 98 | struct FlycheckActor { |
99 | config: FlycheckConfig, | 99 | config: FlycheckConfig, |
100 | workspace_root: PathBuf, | 100 | workspace_root: PathBuf, |
101 | last_update_req: Option<Instant>, | 101 | last_update_req: Option<Instant>, |
@@ -109,9 +109,9 @@ struct FlycheckThread { | |||
109 | check_process: Option<jod_thread::JoinHandle<()>>, | 109 | check_process: Option<jod_thread::JoinHandle<()>>, |
110 | } | 110 | } |
111 | 111 | ||
112 | impl FlycheckThread { | 112 | impl FlycheckActor { |
113 | fn new(config: FlycheckConfig, workspace_root: PathBuf) -> FlycheckThread { | 113 | fn new(config: FlycheckConfig, workspace_root: PathBuf) -> FlycheckActor { |
114 | FlycheckThread { | 114 | FlycheckActor { |
115 | config, | 115 | config, |
116 | workspace_root, | 116 | workspace_root, |
117 | last_update_req: None, | 117 | last_update_req: None, |
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index 64d4e2787..2a7111a88 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs | |||
@@ -9,7 +9,7 @@ use crossbeam_channel::{unbounded, Receiver}; | |||
9 | use lsp_types::Url; | 9 | use lsp_types::Url; |
10 | use parking_lot::RwLock; | 10 | use parking_lot::RwLock; |
11 | use ra_db::{CrateId, SourceRoot, VfsPath}; | 11 | use ra_db::{CrateId, SourceRoot, VfsPath}; |
12 | use ra_flycheck::{Flycheck, FlycheckConfig}; | 12 | use ra_flycheck::{FlycheckConfig, FlycheckHandle}; |
13 | use ra_ide::{Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId}; | 13 | use ra_ide::{Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId}; |
14 | use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target}; | 14 | use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target}; |
15 | use stdx::format_to; | 15 | use stdx::format_to; |
@@ -27,12 +27,15 @@ use crate::{ | |||
27 | }; | 27 | }; |
28 | use rustc_hash::{FxHashMap, FxHashSet}; | 28 | use rustc_hash::{FxHashMap, FxHashSet}; |
29 | 29 | ||
30 | fn create_flycheck(workspaces: &[ProjectWorkspace], config: &FlycheckConfig) -> Option<Flycheck> { | 30 | fn create_flycheck( |
31 | workspaces: &[ProjectWorkspace], | ||
32 | config: &FlycheckConfig, | ||
33 | ) -> Option<FlycheckHandle> { | ||
31 | // FIXME: Figure out the multi-workspace situation | 34 | // FIXME: Figure out the multi-workspace situation |
32 | workspaces.iter().find_map(move |w| match w { | 35 | workspaces.iter().find_map(move |w| match w { |
33 | ProjectWorkspace::Cargo { cargo, .. } => { | 36 | ProjectWorkspace::Cargo { cargo, .. } => { |
34 | let cargo_project_root = cargo.workspace_root().to_path_buf(); | 37 | let cargo_project_root = cargo.workspace_root().to_path_buf(); |
35 | Some(Flycheck::new(config.clone(), cargo_project_root.into())) | 38 | Some(FlycheckHandle::spawn(config.clone(), cargo_project_root.into())) |
36 | } | 39 | } |
37 | ProjectWorkspace::Json { .. } => { | 40 | ProjectWorkspace::Json { .. } => { |
38 | log::warn!("Cargo check watching only supported for cargo workspaces, disabling"); | 41 | log::warn!("Cargo check watching only supported for cargo workspaces, disabling"); |
@@ -63,7 +66,7 @@ pub(crate) struct GlobalState { | |||
63 | pub(crate) analysis_host: AnalysisHost, | 66 | pub(crate) analysis_host: AnalysisHost, |
64 | pub(crate) loader: Box<dyn vfs::loader::Handle>, | 67 | pub(crate) loader: Box<dyn vfs::loader::Handle>, |
65 | pub(crate) task_receiver: Receiver<vfs::loader::Message>, | 68 | pub(crate) task_receiver: Receiver<vfs::loader::Message>, |
66 | pub(crate) flycheck: Option<Flycheck>, | 69 | pub(crate) flycheck: Option<FlycheckHandle>, |
67 | pub(crate) diagnostics: DiagnosticCollection, | 70 | pub(crate) diagnostics: DiagnosticCollection, |
68 | pub(crate) mem_docs: FxHashSet<VfsPath>, | 71 | pub(crate) mem_docs: FxHashSet<VfsPath>, |
69 | pub(crate) vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>, | 72 | pub(crate) vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>, |