mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 09:27:27 +00:00
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 mut roots = Vec::new();
|
||||
roots.push(root.clone());
|
||||
ws.add_roots(&mut roots);
|
||||
roots.extend(ws.to_roots());
|
||||
let (mut vfs, roots) = Vfs::new(roots);
|
||||
let mut load = |path: &Path| {
|
||||
let vfs_file = vfs.load(path);
|
||||
|
|
|
@ -40,7 +40,7 @@ impl ServerWorldState {
|
|||
let mut roots = Vec::new();
|
||||
roots.push(root.clone());
|
||||
for ws in workspaces.iter() {
|
||||
ws.add_roots(&mut roots);
|
||||
roots.extend(ws.to_roots());
|
||||
}
|
||||
let (mut vfs, roots) = Vfs::new(roots);
|
||||
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 {
|
||||
ProjectWorkspace::Json { project } => {
|
||||
let mut roots = Vec::with_capacity(project.roots.len());
|
||||
for root in &project.roots {
|
||||
roots.push(root.path.clone());
|
||||
}
|
||||
roots
|
||||
}
|
||||
ProjectWorkspace::Cargo { cargo, sysroot } => {
|
||||
let mut roots =
|
||||
Vec::with_capacity(cargo.packages().count() + sysroot.crates().count());
|
||||
for pkg in cargo.packages() {
|
||||
roots.push(pkg.root(&cargo).to_path_buf());
|
||||
}
|
||||
for krate in sysroot.crates() {
|
||||
roots.push(krate.root_dir(&sysroot).to_path_buf())
|
||||
}
|
||||
roots
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue