mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Move project discovery
This commit is contained in:
parent
992e1256d0
commit
0a88de809f
2 changed files with 16 additions and 8 deletions
|
@ -14,7 +14,7 @@ use std::{
|
|||
use anyhow::{bail, Context, Result};
|
||||
use ra_cfg::CfgOptions;
|
||||
use ra_db::{CrateGraph, CrateName, Edition, Env, ExternSource, ExternSourceId, FileId};
|
||||
use rustc_hash::FxHashMap;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use serde_json::from_reader;
|
||||
|
||||
pub use crate::{
|
||||
|
@ -57,7 +57,7 @@ impl PackageRoot {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)]
|
||||
pub enum ProjectRoot {
|
||||
ProjectJson(PathBuf),
|
||||
CargoToml(PathBuf),
|
||||
|
@ -128,6 +128,18 @@ impl ProjectRoot {
|
|||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn discover_all(paths: &[impl AsRef<Path>]) -> Vec<ProjectRoot> {
|
||||
let mut res = paths
|
||||
.iter()
|
||||
.filter_map(|it| ProjectRoot::discover(it.as_ref()).ok())
|
||||
.flatten()
|
||||
.collect::<FxHashSet<_>>()
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>();
|
||||
res.sort();
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
impl ProjectWorkspace {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue