aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop')
-rw-r--r--crates/ra_lsp_server/src/main_loop/mod.rs32
1 files changed, 29 insertions, 3 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/mod.rs b/crates/ra_lsp_server/src/main_loop/mod.rs
index 78d93741a..36f08be2f 100644
--- a/crates/ra_lsp_server/src/main_loop/mod.rs
+++ b/crates/ra_lsp_server/src/main_loop/mod.rs
@@ -168,9 +168,35 @@ fn main_loop_inner(
168 let workspaces = vec![ws]; 168 let workspaces = vec![ws];
169 feedback(internal_mode, "workspace loaded", msg_sender); 169 feedback(internal_mode, "workspace loaded", msg_sender);
170 for ws in workspaces.iter() { 170 for ws in workspaces.iter() {
171 for pkg in ws.packages().filter(|pkg| !pkg.is_member(ws)) { 171 // Add each library as constant input. If library is
172 debug!("sending root, {}", pkg.root(ws).to_path_buf().display()); 172 // within the workspace, don't treat it as a library.
173 fs_worker.send(pkg.root(ws).to_path_buf()); 173 //
174 // HACK: If source roots are nested, pick the outer one.
175
176 let mut roots = ws
177 .packages()
178 .filter(|pkg| !pkg.is_member(ws))
179 .filter_map(|pkg| {
180 let root = pkg.root(ws).to_path_buf();
181 if root.starts_with(&ws_root) {
182 None
183 } else {
184 Some(root)
185 }
186 })
187 .collect::<Vec<_>>();
188 roots.sort_by_key(|it| it.as_os_str().len());
189 let unique = roots
190 .iter()
191 .enumerate()
192 .filter(|&(idx, long)| {
193 !roots[..idx].iter().any(|short| long.starts_with(short))
194 })
195 .map(|(_idx, root)| root);
196
197 for root in unique {
198 debug!("sending root, {}", root.display());
199 fs_worker.send(root.to_owned());
174 } 200 }
175 } 201 }
176 state.set_workspaces(workspaces); 202 state.set_workspaces(workspaces);