Rename and change add_roots
to return a Vec
.
This commit is contained in:
parent
00d927a188
commit
614dd3c347
3 changed files with 8 additions and 3 deletions
|
@ -99,7 +99,7 @@ impl BatchDatabase {
|
||||||
let ws = ProjectWorkspace::discover(root.as_ref())?;
|
let ws = ProjectWorkspace::discover(root.as_ref())?;
|
||||||
let mut roots = Vec::new();
|
let mut roots = Vec::new();
|
||||||
roots.push(root.clone());
|
roots.push(root.clone());
|
||||||
ws.add_roots(&mut roots);
|
roots.extend(ws.to_roots());
|
||||||
let (mut vfs, roots) = Vfs::new(roots);
|
let (mut vfs, roots) = Vfs::new(roots);
|
||||||
let mut load = |path: &Path| {
|
let mut load = |path: &Path| {
|
||||||
let vfs_file = vfs.load(path);
|
let vfs_file = vfs.load(path);
|
||||||
|
|
|
@ -40,7 +40,7 @@ impl ServerWorldState {
|
||||||
let mut roots = Vec::new();
|
let mut roots = Vec::new();
|
||||||
roots.push(root.clone());
|
roots.push(root.clone());
|
||||||
for ws in workspaces.iter() {
|
for ws in workspaces.iter() {
|
||||||
ws.add_roots(&mut roots);
|
roots.extend(ws.to_roots());
|
||||||
}
|
}
|
||||||
let (mut vfs, roots) = Vfs::new(roots);
|
let (mut vfs, roots) = Vfs::new(roots);
|
||||||
let roots_to_scan = roots.len();
|
let roots_to_scan = roots.len();
|
||||||
|
|
|
@ -50,20 +50,25 @@ impl ProjectWorkspace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_roots(&self, roots: &mut Vec<PathBuf>) {
|
pub fn to_roots(&self) -> Vec<PathBuf> {
|
||||||
match self {
|
match self {
|
||||||
ProjectWorkspace::Json { project } => {
|
ProjectWorkspace::Json { project } => {
|
||||||
|
let mut roots = Vec::with_capacity(project.roots.len());
|
||||||
for root in &project.roots {
|
for root in &project.roots {
|
||||||
roots.push(root.path.clone());
|
roots.push(root.path.clone());
|
||||||
}
|
}
|
||||||
|
roots
|
||||||
}
|
}
|
||||||
ProjectWorkspace::Cargo { cargo, sysroot } => {
|
ProjectWorkspace::Cargo { cargo, sysroot } => {
|
||||||
|
let mut roots =
|
||||||
|
Vec::with_capacity(cargo.packages().count() + sysroot.crates().count());
|
||||||
for pkg in cargo.packages() {
|
for pkg in cargo.packages() {
|
||||||
roots.push(pkg.root(&cargo).to_path_buf());
|
roots.push(pkg.root(&cargo).to_path_buf());
|
||||||
}
|
}
|
||||||
for krate in sysroot.crates() {
|
for krate in sysroot.crates() {
|
||||||
roots.push(krate.root_dir(&sysroot).to_path_buf())
|
roots.push(krate.root_dir(&sysroot).to_path_buf())
|
||||||
}
|
}
|
||||||
|
roots
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue