From 7cd9b1dd7a91fb3b1e400fd4b47333c9699381f7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 19 Aug 2019 15:41:18 +0300 Subject: don't load sysroot in most heavy tests --- crates/ra_lsp_server/src/config.rs | 5 +++++ crates/ra_lsp_server/src/main_loop.rs | 2 +- crates/ra_lsp_server/src/project_model.rs | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'crates/ra_lsp_server/src') diff --git a/crates/ra_lsp_server/src/config.rs b/crates/ra_lsp_server/src/config.rs index 6dcdc695a..71838b89c 100644 --- a/crates/ra_lsp_server/src/config.rs +++ b/crates/ra_lsp_server/src/config.rs @@ -21,6 +21,10 @@ pub struct ServerConfig { pub exclude_globs: Vec, pub lru_capacity: Option, + + /// For internal usage to make integrated tests faster. + #[serde(deserialize_with = "nullable_bool_true")] + pub with_sysroot: bool, } impl Default for ServerConfig { @@ -30,6 +34,7 @@ impl Default for ServerConfig { show_workspace_loaded: true, exclude_globs: Vec::new(), lru_capacity: None, + with_sysroot: true, } } } diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index b9c99a223..3ee0ad652 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -59,7 +59,7 @@ pub fn main_loop( log::debug!("server_config: {:?}", config); // FIXME: support dynamic workspace loading. let workspaces = { - let ws_worker = workspace_loader(); + let ws_worker = workspace_loader(config.with_sysroot); let mut loaded_workspaces = Vec::new(); for ws_root in &ws_roots { ws_worker.sender().send(ws_root.clone()).unwrap(); diff --git a/crates/ra_lsp_server/src/project_model.rs b/crates/ra_lsp_server/src/project_model.rs index 1130d08de..ad59cde64 100644 --- a/crates/ra_lsp_server/src/project_model.rs +++ b/crates/ra_lsp_server/src/project_model.rs @@ -8,14 +8,14 @@ pub use ra_project_model::{ CargoWorkspace, Package, ProjectWorkspace, Sysroot, Target, TargetKind, }; -pub fn workspace_loader() -> Worker> { +pub fn workspace_loader(with_sysroot: bool) -> Worker> { Worker::>::spawn( "workspace loader", 1, - |input_receiver, output_sender| { + move |input_receiver, output_sender| { input_receiver .into_iter() - .map(|path| ProjectWorkspace::discover(path.as_path())) + .map(|path| ProjectWorkspace::discover_with_sysroot(path.as_path(), with_sysroot)) .try_for_each(|it| output_sender.send(it)) .unwrap() }, -- cgit v1.2.3