aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/flycheck/src/lib.rs1
-rw-r--r--crates/ra_project_model/src/project_json.rs6
-rw-r--r--crates/rust-analyzer/src/config.rs2
-rw-r--r--crates/rust-analyzer/src/global_state.rs2
-rw-r--r--crates/rust-analyzer/src/lsp_ext.rs6
-rw-r--r--crates/rust-analyzer/src/main_loop.rs14
-rw-r--r--crates/rust-analyzer/src/reload.rs5
7 files changed, 21 insertions, 15 deletions
diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs
index 1023d3040..844b093d4 100644
--- a/crates/flycheck/src/lib.rs
+++ b/crates/flycheck/src/lib.rs
@@ -132,6 +132,7 @@ impl FlycheckActor {
132 self.cancel_check_process(); 132 self.cancel_check_process();
133 133
134 let mut command = self.check_command(); 134 let mut command = self.check_command();
135 log::info!("restart flycheck {:?}", command);
135 command.stdout(Stdio::piped()).stderr(Stdio::null()).stdin(Stdio::null()); 136 command.stdout(Stdio::piped()).stderr(Stdio::null()).stdin(Stdio::null());
136 if let Ok(child) = command.spawn().map(JodChild) { 137 if let Ok(child) = command.spawn().map(JodChild) {
137 self.cargo_handle = Some(CargoHandle::spawn(child)); 138 self.cargo_handle = Some(CargoHandle::spawn(child));
diff --git a/crates/ra_project_model/src/project_json.rs b/crates/ra_project_model/src/project_json.rs
index 9fe1e2dcb..b0fe09333 100644
--- a/crates/ra_project_model/src/project_json.rs
+++ b/crates/ra_project_model/src/project_json.rs
@@ -10,7 +10,7 @@ use serde::{de, Deserialize};
10use stdx::split_delim; 10use stdx::split_delim;
11 11
12/// Roots and crates that compose this Rust project. 12/// Roots and crates that compose this Rust project.
13#[derive(Clone, Debug)] 13#[derive(Clone, Debug, Eq, PartialEq)]
14pub struct ProjectJson { 14pub struct ProjectJson {
15 pub(crate) roots: Vec<Root>, 15 pub(crate) roots: Vec<Root>,
16 pub(crate) crates: Vec<Crate>, 16 pub(crate) crates: Vec<Crate>,
@@ -18,14 +18,14 @@ pub struct ProjectJson {
18 18
19/// A root points to the directory which contains Rust crates. rust-analyzer watches all files in 19/// A root points to the directory which contains Rust crates. rust-analyzer watches all files in
20/// all roots. Roots might be nested. 20/// all roots. Roots might be nested.
21#[derive(Clone, Debug)] 21#[derive(Clone, Debug, Eq, PartialEq)]
22pub struct Root { 22pub struct Root {
23 pub(crate) path: AbsPathBuf, 23 pub(crate) path: AbsPathBuf,
24} 24}
25 25
26/// A crate points to the root module of a crate and lists the dependencies of the crate. This is 26/// A crate points to the root module of a crate and lists the dependencies of the crate. This is
27/// useful in creating the crate graph. 27/// useful in creating the crate graph.
28#[derive(Clone, Debug)] 28#[derive(Clone, Debug, Eq, PartialEq)]
29pub struct Crate { 29pub struct Crate {
30 pub(crate) root_module: AbsPathBuf, 30 pub(crate) root_module: AbsPathBuf,
31 pub(crate) edition: Edition, 31 pub(crate) edition: Edition,
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 6b17ce18b..6c311648a 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -44,7 +44,7 @@ pub struct Config {
44 pub root_path: AbsPathBuf, 44 pub root_path: AbsPathBuf,
45} 45}
46 46
47#[derive(Debug, Clone)] 47#[derive(Debug, Clone, Eq, PartialEq)]
48pub enum LinkedProject { 48pub enum LinkedProject {
49 ProjectManifest(ProjectManifest), 49 ProjectManifest(ProjectManifest),
50 InlineJsonProject(ProjectJson), 50 InlineJsonProject(ProjectJson),
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs
index b8aa1e5b5..b7b4edf66 100644
--- a/crates/rust-analyzer/src/global_state.rs
+++ b/crates/rust-analyzer/src/global_state.rs
@@ -27,7 +27,7 @@ use crate::{
27 Result, 27 Result,
28}; 28};
29 29
30#[derive(Eq, PartialEq)] 30#[derive(Eq, PartialEq, Copy, Clone)]
31pub(crate) enum Status { 31pub(crate) enum Status {
32 Loading, 32 Loading,
33 Ready, 33 Ready,
diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs
index 1befe678c..82207bbb8 100644
--- a/crates/rust-analyzer/src/lsp_ext.rs
+++ b/crates/rust-analyzer/src/lsp_ext.rs
@@ -14,12 +14,12 @@ impl Request for AnalyzerStatus {
14 const METHOD: &'static str = "rust-analyzer/analyzerStatus"; 14 const METHOD: &'static str = "rust-analyzer/analyzerStatus";
15} 15}
16 16
17pub enum CollectGarbage {} 17pub enum ReloadWorkspace {}
18 18
19impl Request for CollectGarbage { 19impl Request for ReloadWorkspace {
20 type Params = (); 20 type Params = ();
21 type Result = (); 21 type Result = ();
22 const METHOD: &'static str = "rust-analyzer/collectGarbage"; 22 const METHOD: &'static str = "rust-analyzer/reloadWorkspace";
23} 23}
24 24
25pub enum SyntaxTree {} 25pub enum SyntaxTree {}
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 2ce1441b6..e03038b25 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -136,7 +136,7 @@ impl GlobalState {
136 log::info!("queued count = {}", queue_count); 136 log::info!("queued count = {}", queue_count);
137 } 137 }
138 138
139 let mut became_ready = false; 139 let prev_status = self.status;
140 match event { 140 match event {
141 Event::Lsp(msg) => match msg { 141 Event::Lsp(msg) => match msg {
142 lsp_server::Message::Request(req) => self.on_request(loop_start, req)?, 142 lsp_server::Message::Request(req) => self.on_request(loop_start, req)?,
@@ -168,15 +168,17 @@ impl GlobalState {
168 } 168 }
169 } 169 }
170 vfs::loader::Message::Progress { n_total, n_done } => { 170 vfs::loader::Message::Progress { n_total, n_done } => {
171 if n_total > 0 { 171 if n_total == 0 {
172 self.status = Status::Ready;
173 } else {
172 let state = if n_done == 0 { 174 let state = if n_done == 0 {
175 self.status = Status::Loading;
173 Progress::Begin 176 Progress::Begin
174 } else if n_done < n_total { 177 } else if n_done < n_total {
175 Progress::Report 178 Progress::Report
176 } else { 179 } else {
177 assert_eq!(n_done, n_total); 180 assert_eq!(n_done, n_total);
178 self.status = Status::Ready; 181 self.status = Status::Ready;
179 became_ready = true;
180 Progress::End 182 Progress::End
181 }; 183 };
182 self.report_progress( 184 self.report_progress(
@@ -233,13 +235,13 @@ impl GlobalState {
233 } 235 }
234 236
235 let state_changed = self.process_changes(); 237 let state_changed = self.process_changes();
236 if became_ready { 238 if prev_status == Status::Loading && self.status == Status::Ready {
237 if let Some(flycheck) = &self.flycheck { 239 if let Some(flycheck) = &self.flycheck {
238 flycheck.handle.update(); 240 flycheck.handle.update();
239 } 241 }
240 } 242 }
241 243
242 if self.status == Status::Ready && (state_changed || became_ready) { 244 if self.status == Status::Ready && (state_changed || prev_status == Status::Loading) {
243 let subscriptions = self 245 let subscriptions = self
244 .mem_docs 246 .mem_docs
245 .iter() 247 .iter()
@@ -276,7 +278,7 @@ impl GlobalState {
276 self.register_request(&req, request_received); 278 self.register_request(&req, request_received);
277 279
278 RequestDispatcher { req: Some(req), global_state: self } 280 RequestDispatcher { req: Some(req), global_state: self }
279 .on_sync::<lsp_ext::CollectGarbage>(|s, ()| Ok(s.analysis_host.collect_garbage()))? 281 .on_sync::<lsp_ext::ReloadWorkspace>(|s, ()| Ok(s.reload()))?
280 .on_sync::<lsp_ext::JoinLines>(|s, p| handlers::handle_join_lines(s.snapshot(), p))? 282 .on_sync::<lsp_ext::JoinLines>(|s, p| handlers::handle_join_lines(s.snapshot(), p))?
281 .on_sync::<lsp_ext::OnEnter>(|s, p| handlers::handle_on_enter(s.snapshot(), p))? 283 .on_sync::<lsp_ext::OnEnter>(|s, p| handlers::handle_on_enter(s.snapshot(), p))?
282 .on_sync::<lsp_types::request::Shutdown>(|_, ()| Ok(()))? 284 .on_sync::<lsp_types::request::Shutdown>(|_, ()| Ok(()))?
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index ec71f8b29..0c1fd1b8b 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -19,11 +19,14 @@ impl GlobalState {
19 if self.config.lru_capacity != old_config.lru_capacity { 19 if self.config.lru_capacity != old_config.lru_capacity {
20 self.analysis_host.update_lru_capacity(old_config.lru_capacity); 20 self.analysis_host.update_lru_capacity(old_config.lru_capacity);
21 } 21 }
22 if self.config.flycheck != old_config.flycheck { 22 if self.config.linked_projects != old_config.linked_projects {
23 self.reload()
24 } else if self.config.flycheck != old_config.flycheck {
23 self.reload_flycheck(); 25 self.reload_flycheck();
24 } 26 }
25 } 27 }
26 pub(crate) fn reload(&mut self) { 28 pub(crate) fn reload(&mut self) {
29 log::info!("reloading projects: {:?}", self.config.linked_projects);
27 let workspaces = { 30 let workspaces = {
28 if self.config.linked_projects.is_empty() 31 if self.config.linked_projects.is_empty()
29 && self.config.notifications.cargo_toml_not_found 32 && self.config.notifications.cargo_toml_not_found