diff options
-rw-r--r-- | crates/ra_batch/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/server_world.rs | 2 | ||||
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 7 |
3 files changed, 8 insertions, 3 deletions
diff --git a/crates/ra_batch/src/lib.rs b/crates/ra_batch/src/lib.rs index 2db038063..c6d10107d 100644 --- a/crates/ra_batch/src/lib.rs +++ b/crates/ra_batch/src/lib.rs | |||
@@ -99,7 +99,7 @@ impl BatchDatabase { | |||
99 | let ws = ProjectWorkspace::discover(root.as_ref())?; | 99 | let ws = ProjectWorkspace::discover(root.as_ref())?; |
100 | let mut roots = Vec::new(); | 100 | let mut roots = Vec::new(); |
101 | roots.push(root.clone()); | 101 | roots.push(root.clone()); |
102 | ws.add_roots(&mut roots); | 102 | roots.extend(ws.to_roots()); |
103 | let (mut vfs, roots) = Vfs::new(roots); | 103 | let (mut vfs, roots) = Vfs::new(roots); |
104 | let mut load = |path: &Path| { | 104 | let mut load = |path: &Path| { |
105 | let vfs_file = vfs.load(path); | 105 | let vfs_file = vfs.load(path); |
diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs index 4625a26a7..7163568b9 100644 --- a/crates/ra_lsp_server/src/server_world.rs +++ b/crates/ra_lsp_server/src/server_world.rs | |||
@@ -40,7 +40,7 @@ impl ServerWorldState { | |||
40 | let mut roots = Vec::new(); | 40 | let mut roots = Vec::new(); |
41 | roots.push(root.clone()); | 41 | roots.push(root.clone()); |
42 | for ws in workspaces.iter() { | 42 | for ws in workspaces.iter() { |
43 | ws.add_roots(&mut roots); | 43 | roots.extend(ws.to_roots()); |
44 | } | 44 | } |
45 | let (mut vfs, roots) = Vfs::new(roots); | 45 | let (mut vfs, roots) = Vfs::new(roots); |
46 | let roots_to_scan = roots.len(); | 46 | let roots_to_scan = roots.len(); |
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index ded222446..c566ec0fb 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs | |||
@@ -50,20 +50,25 @@ impl ProjectWorkspace { | |||
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | pub fn add_roots(&self, roots: &mut Vec<PathBuf>) { | 53 | pub fn to_roots(&self) -> Vec<PathBuf> { |
54 | match self { | 54 | match self { |
55 | ProjectWorkspace::Json { project } => { | 55 | ProjectWorkspace::Json { project } => { |
56 | let mut roots = Vec::with_capacity(project.roots.len()); | ||
56 | for root in &project.roots { | 57 | for root in &project.roots { |
57 | roots.push(root.path.clone()); | 58 | roots.push(root.path.clone()); |
58 | } | 59 | } |
60 | roots | ||
59 | } | 61 | } |
60 | ProjectWorkspace::Cargo { cargo, sysroot } => { | 62 | ProjectWorkspace::Cargo { cargo, sysroot } => { |
63 | let mut roots = | ||
64 | Vec::with_capacity(cargo.packages().count() + sysroot.crates().count()); | ||
61 | for pkg in cargo.packages() { | 65 | for pkg in cargo.packages() { |
62 | roots.push(pkg.root(&cargo).to_path_buf()); | 66 | roots.push(pkg.root(&cargo).to_path_buf()); |
63 | } | 67 | } |
64 | for krate in sysroot.crates() { | 68 | for krate in sysroot.crates() { |
65 | roots.push(krate.root_dir(&sysroot).to_path_buf()) | 69 | roots.push(krate.root_dir(&sysroot).to_path_buf()) |
66 | } | 70 | } |
71 | roots | ||
67 | } | 72 | } |
68 | } | 73 | } |
69 | } | 74 | } |