diff options
Diffstat (limited to 'crates/rust-analyzer/src/reload.rs')
-rw-r--r-- | crates/rust-analyzer/src/reload.rs | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index d7ae00b07..1907f2f13 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs | |||
@@ -5,7 +5,7 @@ use flycheck::FlycheckHandle; | |||
5 | use ra_db::{CrateGraph, SourceRoot, VfsPath}; | 5 | use ra_db::{CrateGraph, SourceRoot, VfsPath}; |
6 | use ra_ide::AnalysisChange; | 6 | use ra_ide::AnalysisChange; |
7 | use ra_prof::profile; | 7 | use ra_prof::profile; |
8 | use ra_project_model::{PackageRoot, ProcMacroClient, ProjectWorkspace}; | 8 | use ra_project_model::{ProcMacroClient, ProjectWorkspace}; |
9 | use vfs::{file_set::FileSetConfig, AbsPath, AbsPathBuf, ChangeKind}; | 9 | use vfs::{file_set::FileSetConfig, AbsPath, AbsPathBuf, ChangeKind}; |
10 | 10 | ||
11 | use crate::{ | 11 | use crate::{ |
@@ -149,8 +149,10 @@ impl GlobalState { | |||
149 | watchers: workspaces | 149 | watchers: workspaces |
150 | .iter() | 150 | .iter() |
151 | .flat_map(ProjectWorkspace::to_roots) | 151 | .flat_map(ProjectWorkspace::to_roots) |
152 | .filter(PackageRoot::is_member) | 152 | .filter(|it| it.is_member) |
153 | .map(|root| format!("{}/**/*.rs", root.path().display())) | 153 | .flat_map(|root| { |
154 | root.include.into_iter().map(|it| format!("{}/**/*.rs", it.display())) | ||
155 | }) | ||
154 | .map(|glob_pattern| lsp_types::FileSystemWatcher { glob_pattern, kind: None }) | 156 | .map(|glob_pattern| lsp_types::FileSystemWatcher { glob_pattern, kind: None }) |
155 | .collect(), | 157 | .collect(), |
156 | }; | 158 | }; |
@@ -261,31 +263,23 @@ impl ProjectFolders { | |||
261 | let mut local_filesets = vec![]; | 263 | let mut local_filesets = vec![]; |
262 | 264 | ||
263 | for root in workspaces.iter().flat_map(|it| it.to_roots()) { | 265 | for root in workspaces.iter().flat_map(|it| it.to_roots()) { |
264 | let path = root.path().to_owned(); | 266 | let file_set_roots: Vec<VfsPath> = |
265 | 267 | root.include.iter().cloned().map(VfsPath::from).collect(); | |
266 | let mut file_set_roots: Vec<VfsPath> = vec![]; | ||
267 | 268 | ||
268 | let entry = if root.is_member() { | 269 | let entry = { |
269 | vfs::loader::Entry::local_cargo_package(path.to_path_buf()) | 270 | let mut dirs = vfs::loader::Directories::default(); |
270 | } else { | 271 | dirs.extensions.push("rs".into()); |
271 | vfs::loader::Entry::cargo_package_dependency(path.to_path_buf()) | 272 | dirs.include.extend(root.include); |
273 | dirs.exclude.extend(root.exclude); | ||
274 | vfs::loader::Entry::Directories(dirs) | ||
272 | }; | 275 | }; |
273 | res.load.push(entry); | ||
274 | if root.is_member() { | ||
275 | res.watch.push(res.load.len() - 1); | ||
276 | } | ||
277 | 276 | ||
278 | if let Some(out_dir) = root.out_dir() { | 277 | if root.is_member { |
279 | let out_dir = out_dir.to_path_buf(); | 278 | res.watch.push(res.load.len()); |
280 | res.load.push(vfs::loader::Entry::rs_files_recursively(out_dir.clone())); | ||
281 | if root.is_member() { | ||
282 | res.watch.push(res.load.len() - 1); | ||
283 | } | ||
284 | file_set_roots.push(out_dir.into()); | ||
285 | } | 279 | } |
286 | file_set_roots.push(path.to_path_buf().into()); | 280 | res.load.push(entry); |
287 | 281 | ||
288 | if root.is_member() { | 282 | if root.is_member { |
289 | local_filesets.push(fsc.len()); | 283 | local_filesets.push(fsc.len()); |
290 | } | 284 | } |
291 | fsc.add_file_set(file_set_roots) | 285 | fsc.add_file_set(file_set_roots) |