mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
introduce ra_vfs_glob crate
It manages exclusion rules for the vfs crate
This commit is contained in:
parent
c971869104
commit
34203256bf
12 changed files with 173 additions and 143 deletions
|
@ -1,5 +1,3 @@
|
|||
mod vfs_filter;
|
||||
|
||||
use std::{collections::HashSet, error::Error, path::Path};
|
||||
|
||||
use rustc_hash::FxHashMap;
|
||||
|
@ -7,8 +5,8 @@ use rustc_hash::FxHashMap;
|
|||
use ra_db::{CrateGraph, FileId, SourceRootId};
|
||||
use ra_ide_api::{AnalysisChange, AnalysisHost};
|
||||
use ra_project_model::{PackageRoot, ProjectWorkspace};
|
||||
use ra_vfs::{Vfs, VfsChange};
|
||||
use vfs_filter::IncludeRustFiles;
|
||||
use ra_vfs::{RootEntry, Vfs, VfsChange};
|
||||
use ra_vfs_glob::RustPackageFilterBuilder;
|
||||
|
||||
type Result<T> = std::result::Result<T, Box<dyn Error + Send + Sync>>;
|
||||
|
||||
|
@ -23,7 +21,19 @@ pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap<SourceRootId,
|
|||
let root = std::env::current_dir()?.join(root);
|
||||
let ws = ProjectWorkspace::discover(root.as_ref())?;
|
||||
let project_roots = ws.to_roots();
|
||||
let (mut vfs, roots) = Vfs::new(IncludeRustFiles::from_roots(project_roots.clone()).collect());
|
||||
let (mut vfs, roots) = Vfs::new(
|
||||
project_roots
|
||||
.iter()
|
||||
.map(|pkg_root| {
|
||||
RootEntry::new(
|
||||
pkg_root.path().clone(),
|
||||
RustPackageFilterBuilder::default()
|
||||
.set_member(pkg_root.is_member())
|
||||
.into_vfs_filter(),
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
);
|
||||
let crate_graph = ws.to_crate_graph(&mut |path: &Path| {
|
||||
let vfs_file = vfs.load(path);
|
||||
log::debug!("vfs file {:?} -> {:?}", path, vfs_file);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue