From e7bb82c3a494e08cbcd283b8292579a9cf0bb1a3 Mon Sep 17 00:00:00 2001 From: Wilco Kusee Date: Fri, 3 Jan 2020 15:04:54 +0100 Subject: Allow disabling Cargo.toml not found error --- crates/ra_lsp_server/src/main_loop.rs | 39 ++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 4336583fe..5ca37981e 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -13,6 +13,7 @@ use lsp_types::{ClientCapabilities, NumberOrString}; use ra_cargo_watch::{CheckOptions, CheckTask}; use ra_ide::{Canceled, FeatureFlags, FileId, LibraryData, SourceRootId}; use ra_prof::profile; +use ra_project_model::WorkspaceError; use ra_vfs::{VfsTask, Watch}; use relative_path::RelativePathBuf; use rustc_hash::FxHashSet; @@ -62,6 +63,22 @@ pub fn main_loop( let mut loop_state = LoopState::default(); let mut world_state = { + let feature_flags = { + let mut ff = FeatureFlags::default(); + for (flag, value) in config.feature_flags { + if ff.set(flag.as_str(), value).is_err() { + log::error!("unknown feature flag: {:?}", flag); + show_message( + req::MessageType::Error, + format!("unknown feature flag: {:?}", flag), + &connection.sender, + ); + } + } + ff + }; + log::info!("feature_flags: {:#?}", feature_flags); + // FIXME: support dynamic workspace loading. let workspaces = { let mut loaded_workspaces = Vec::new(); @@ -75,7 +92,11 @@ pub fn main_loop( Ok(workspace) => loaded_workspaces.push(workspace), Err(e) => { log::error!("loading workspace failed: {}", e); - + if let WorkspaceError::CargoTomlNotFound(_) = e { + if !feature_flags.get("notifications.cargo-toml-not-found") { + continue; + } + } show_message( req::MessageType::Error, format!("rust-analyzer failed to load workspace: {}", e), @@ -136,22 +157,6 @@ pub fn main_loop( } }; - let feature_flags = { - let mut ff = FeatureFlags::default(); - for (flag, value) in config.feature_flags { - if ff.set(flag.as_str(), value).is_err() { - log::error!("unknown feature flag: {:?}", flag); - show_message( - req::MessageType::Error, - format!("unknown feature flag: {:?}", flag), - &connection.sender, - ); - } - } - ff - }; - log::info!("feature_flags: {:#?}", feature_flags); - WorldState::new( ws_roots, workspaces, -- cgit v1.2.3 From 003620f0d61c1c8792453294d9b2ef535afc2831 Mon Sep 17 00:00:00 2001 From: Wilco Kusee Date: Wed, 8 Jan 2020 14:04:47 +0100 Subject: Use downcasting for CargoTomlNotFoundError --- crates/ra_lsp_server/src/main_loop.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 5ca37981e..53c6834d0 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -13,7 +13,6 @@ use lsp_types::{ClientCapabilities, NumberOrString}; use ra_cargo_watch::{CheckOptions, CheckTask}; use ra_ide::{Canceled, FeatureFlags, FileId, LibraryData, SourceRootId}; use ra_prof::profile; -use ra_project_model::WorkspaceError; use ra_vfs::{VfsTask, Watch}; use relative_path::RelativePathBuf; use rustc_hash::FxHashSet; @@ -92,7 +91,8 @@ pub fn main_loop( Ok(workspace) => loaded_workspaces.push(workspace), Err(e) => { log::error!("loading workspace failed: {}", e); - if let WorkspaceError::CargoTomlNotFound(_) = e { + if let Some(ra_project_model::CargoTomlNotFoundError(_)) = e.downcast_ref() + { if !feature_flags.get("notifications.cargo-toml-not-found") { continue; } -- cgit v1.2.3