diff options
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/mod.rs | 32 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/path_map.rs | 4 |
2 files changed, 33 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); |
diff --git a/crates/ra_lsp_server/src/path_map.rs b/crates/ra_lsp_server/src/path_map.rs index 87eabf9be..a624043d8 100644 --- a/crates/ra_lsp_server/src/path_map.rs +++ b/crates/ra_lsp_server/src/path_map.rs | |||
@@ -79,6 +79,10 @@ impl FileResolver for PathMap { | |||
79 | let path = normalize(&path); | 79 | let path = normalize(&path); |
80 | self.get_id(&path) | 80 | self.get_id(&path) |
81 | } | 81 | } |
82 | |||
83 | fn debug_path(&self, file_id: FileId) -> Option<PathBuf> { | ||
84 | Some(self.get_path(file_id).to_owned()) | ||
85 | } | ||
82 | } | 86 | } |
83 | 87 | ||
84 | fn normalize(path: &Path) -> PathBuf { | 88 | fn normalize(path: &Path) -> PathBuf { |