diff options
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r-- | crates/ra_lsp_server/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 16 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 5 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/world.rs | 4 |
4 files changed, 13 insertions, 14 deletions
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index 4ee3fb49f..5df0496dd 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml | |||
@@ -26,7 +26,7 @@ lsp-server = "0.3.0" | |||
26 | ra_project_model = { path = "../ra_project_model" } | 26 | ra_project_model = { path = "../ra_project_model" } |
27 | ra_prof = { path = "../ra_prof" } | 27 | ra_prof = { path = "../ra_prof" } |
28 | ra_vfs_glob = { path = "../ra_vfs_glob" } | 28 | ra_vfs_glob = { path = "../ra_vfs_glob" } |
29 | env_logger = { version = "0.7.1", default-features = false, features = ["humantime"] } | 29 | env_logger = { version = "0.7.1", default-features = false } |
30 | ra_cargo_watch = { path = "../ra_cargo_watch" } | 30 | ra_cargo_watch = { path = "../ra_cargo_watch" } |
31 | either = "1.5" | 31 | either = "1.5" |
32 | 32 | ||
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 7822be2e2..83adf9711 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -210,7 +210,7 @@ pub fn main_loop( | |||
210 | )?; | 210 | )?; |
211 | } | 211 | } |
212 | } | 212 | } |
213 | 213 | world_state.analysis_host.request_cancellation(); | |
214 | log::info!("waiting for tasks to finish..."); | 214 | log::info!("waiting for tasks to finish..."); |
215 | task_receiver.into_iter().for_each(|task| { | 215 | task_receiver.into_iter().for_each(|task| { |
216 | on_task(task, &connection.sender, &mut loop_state.pending_requests, &mut world_state) | 216 | on_task(task, &connection.sender, &mut loop_state.pending_requests, &mut world_state) |
@@ -586,12 +586,14 @@ fn on_notification( | |||
586 | 586 | ||
587 | fn on_check_task( | 587 | fn on_check_task( |
588 | task: CheckTask, | 588 | task: CheckTask, |
589 | world_state: &WorldState, | 589 | world_state: &mut WorldState, |
590 | task_sender: &Sender<Task>, | 590 | task_sender: &Sender<Task>, |
591 | ) -> Result<()> { | 591 | ) -> Result<()> { |
592 | match task { | 592 | match task { |
593 | CheckTask::ClearDiagnostics => { | 593 | CheckTask::ClearDiagnostics => { |
594 | let cleared_files = world_state.check_watcher.state.write().clear(); | 594 | let state = Arc::get_mut(&mut world_state.check_watcher.state) |
595 | .expect("couldn't get check watcher state as mutable"); | ||
596 | let cleared_files = state.clear(); | ||
595 | 597 | ||
596 | // Send updated diagnostics for each cleared file | 598 | // Send updated diagnostics for each cleared file |
597 | for url in cleared_files { | 599 | for url in cleared_files { |
@@ -600,11 +602,9 @@ fn on_check_task( | |||
600 | } | 602 | } |
601 | 603 | ||
602 | CheckTask::AddDiagnostic(url, diagnostic) => { | 604 | CheckTask::AddDiagnostic(url, diagnostic) => { |
603 | world_state | 605 | let state = Arc::get_mut(&mut world_state.check_watcher.state) |
604 | .check_watcher | 606 | .expect("couldn't get check watcher state as mutable"); |
605 | .state | 607 | state.add_diagnostic_with_fixes(url.clone(), diagnostic); |
606 | .write() | ||
607 | .add_diagnostic_with_fixes(url.clone(), diagnostic); | ||
608 | 608 | ||
609 | // We manually send a diagnostic update when the watcher asks | 609 | // We manually send a diagnostic update when the watcher asks |
610 | // us to, to avoid the issue of having to change the file to | 610 | // us to, to avoid the issue of having to change the file to |
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 8e43f0575..666f2ee29 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -674,8 +674,7 @@ pub fn handle_code_action( | |||
674 | res.push(action.into()); | 674 | res.push(action.into()); |
675 | } | 675 | } |
676 | 676 | ||
677 | for fix in world.check_watcher.read().fixes_for(¶ms.text_document.uri).into_iter().flatten() | 677 | for fix in world.check_watcher.fixes_for(¶ms.text_document.uri).into_iter().flatten() { |
678 | { | ||
679 | let fix_range = fix.location.range.conv_with(&line_index); | 678 | let fix_range = fix.location.range.conv_with(&line_index); |
680 | if fix_range.intersection(&range).is_none() { | 679 | if fix_range.intersection(&range).is_none() { |
681 | continue; | 680 | continue; |
@@ -895,7 +894,7 @@ pub fn publish_diagnostics( | |||
895 | tags: None, | 894 | tags: None, |
896 | }) | 895 | }) |
897 | .collect(); | 896 | .collect(); |
898 | if let Some(check_diags) = world.check_watcher.read().diagnostics_for(&uri) { | 897 | if let Some(check_diags) = world.check_watcher.diagnostics_for(&uri) { |
899 | diagnostics.extend(check_diags.iter().cloned()); | 898 | diagnostics.extend(check_diags.iter().cloned()); |
900 | } | 899 | } |
901 | Ok(req::PublishDiagnosticsParams { uri, diagnostics, version: None }) | 900 | Ok(req::PublishDiagnosticsParams { uri, diagnostics, version: None }) |
diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index e7a0acfc7..3059ef9ec 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs | |||
@@ -63,7 +63,7 @@ pub struct WorldSnapshot { | |||
63 | pub workspaces: Arc<Vec<ProjectWorkspace>>, | 63 | pub workspaces: Arc<Vec<ProjectWorkspace>>, |
64 | pub analysis: Analysis, | 64 | pub analysis: Analysis, |
65 | pub latest_requests: Arc<RwLock<LatestRequests>>, | 65 | pub latest_requests: Arc<RwLock<LatestRequests>>, |
66 | pub check_watcher: Arc<RwLock<CheckState>>, | 66 | pub check_watcher: CheckState, |
67 | vfs: Arc<RwLock<Vfs>>, | 67 | vfs: Arc<RwLock<Vfs>>, |
68 | } | 68 | } |
69 | 69 | ||
@@ -220,7 +220,7 @@ impl WorldState { | |||
220 | analysis: self.analysis_host.analysis(), | 220 | analysis: self.analysis_host.analysis(), |
221 | vfs: Arc::clone(&self.vfs), | 221 | vfs: Arc::clone(&self.vfs), |
222 | latest_requests: Arc::clone(&self.latest_requests), | 222 | latest_requests: Arc::clone(&self.latest_requests), |
223 | check_watcher: self.check_watcher.state.clone(), | 223 | check_watcher: (*self.check_watcher.state).clone(), |
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||