aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorWilco Kusee <[email protected]>2020-01-03 14:04:54 +0000
committerWilco Kusee <[email protected]>2020-01-03 14:04:54 +0000
commite7bb82c3a494e08cbcd283b8292579a9cf0bb1a3 (patch)
tree8d47f5c3efb1260bc7dc0b75c824613afa5b069b /crates
parent6c321d7318b94ee93dc60dc88d1e68afa94e8c4f (diff)
Allow disabling Cargo.toml not found error
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/src/feature_flags.rs1
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs39
-rw-r--r--crates/ra_project_model/src/lib.rs3
3 files changed, 24 insertions, 19 deletions
diff --git a/crates/ra_ide/src/feature_flags.rs b/crates/ra_ide/src/feature_flags.rs
index de4ae513d..85617640d 100644
--- a/crates/ra_ide/src/feature_flags.rs
+++ b/crates/ra_ide/src/feature_flags.rs
@@ -56,6 +56,7 @@ impl Default for FeatureFlags {
56 ("completion.insertion.add-call-parenthesis", true), 56 ("completion.insertion.add-call-parenthesis", true),
57 ("completion.enable-postfix", true), 57 ("completion.enable-postfix", true),
58 ("notifications.workspace-loaded", true), 58 ("notifications.workspace-loaded", true),
59 ("notifications.cargo-toml-not-found", true),
59 ]) 60 ])
60 } 61 }
61} 62}
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};
13use ra_cargo_watch::{CheckOptions, CheckTask}; 13use ra_cargo_watch::{CheckOptions, CheckTask};
14use ra_ide::{Canceled, FeatureFlags, FileId, LibraryData, SourceRootId}; 14use ra_ide::{Canceled, FeatureFlags, FileId, LibraryData, SourceRootId};
15use ra_prof::profile; 15use ra_prof::profile;
16use ra_project_model::WorkspaceError;
16use ra_vfs::{VfsTask, Watch}; 17use ra_vfs::{VfsTask, Watch};
17use relative_path::RelativePathBuf; 18use relative_path::RelativePathBuf;
18use rustc_hash::FxHashSet; 19use rustc_hash::FxHashSet;
@@ -62,6 +63,22 @@ pub fn main_loop(
62 63
63 let mut loop_state = LoopState::default(); 64 let mut loop_state = LoopState::default();
64 let mut world_state = { 65 let mut world_state = {
66 let feature_flags = {
67 let mut ff = FeatureFlags::default();
68 for (flag, value) in config.feature_flags {
69 if ff.set(flag.as_str(), value).is_err() {
70 log::error!("unknown feature flag: {:?}", flag);
71 show_message(
72 req::MessageType::Error,
73 format!("unknown feature flag: {:?}", flag),
74 &connection.sender,
75 );
76 }
77 }
78 ff
79 };
80 log::info!("feature_flags: {:#?}", feature_flags);
81
65 // FIXME: support dynamic workspace loading. 82 // FIXME: support dynamic workspace loading.
66 let workspaces = { 83 let workspaces = {
67 let mut loaded_workspaces = Vec::new(); 84 let mut loaded_workspaces = Vec::new();
@@ -75,7 +92,11 @@ pub fn main_loop(
75 Ok(workspace) => loaded_workspaces.push(workspace), 92 Ok(workspace) => loaded_workspaces.push(workspace),
76 Err(e) => { 93 Err(e) => {
77 log::error!("loading workspace failed: {}", e); 94 log::error!("loading workspace failed: {}", e);
78 95 if let WorkspaceError::CargoTomlNotFound(_) = e {
96 if !feature_flags.get("notifications.cargo-toml-not-found") {
97 continue;
98 }
99 }
79 show_message( 100 show_message(
80 req::MessageType::Error, 101 req::MessageType::Error,
81 format!("rust-analyzer failed to load workspace: {}", e), 102 format!("rust-analyzer failed to load workspace: {}", e),
@@ -136,22 +157,6 @@ pub fn main_loop(
136 } 157 }
137 }; 158 };
138 159
139 let feature_flags = {
140 let mut ff = FeatureFlags::default();
141 for (flag, value) in config.feature_flags {
142 if ff.set(flag.as_str(), value).is_err() {
143 log::error!("unknown feature flag: {:?}", flag);
144 show_message(
145 req::MessageType::Error,
146 format!("unknown feature flag: {:?}", flag),
147 &connection.sender,
148 );
149 }
150 }
151 ff
152 };
153 log::info!("feature_flags: {:#?}", feature_flags);
154
155 WorldState::new( 160 WorldState::new(
156 ws_roots, 161 ws_roots,
157 workspaces, 162 workspaces,
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index c07c54936..2aa9270c8 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -17,12 +17,11 @@ use ra_db::{CrateGraph, CrateId, Edition, Env, FileId};
17use rustc_hash::FxHashMap; 17use rustc_hash::FxHashMap;
18use serde_json::from_reader; 18use serde_json::from_reader;
19 19
20use crate::workspace_error::WorkspaceError;
21
22pub use crate::{ 20pub use crate::{
23 cargo_workspace::{CargoFeatures, CargoWorkspace, Package, Target, TargetKind}, 21 cargo_workspace::{CargoFeatures, CargoWorkspace, Package, Target, TargetKind},
24 json_project::JsonProject, 22 json_project::JsonProject,
25 sysroot::Sysroot, 23 sysroot::Sysroot,
24 workspace_error::WorkspaceError,
26}; 25};
27 26
28#[derive(Debug, Clone)] 27#[derive(Debug, Clone)]