From 34203256bf8f8ea12b233e0fb49b42bd8c423281 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 6 Aug 2019 13:00:37 +0200 Subject: introduce ra_vfs_glob crate It manages exclusion rules for the vfs crate --- crates/ra_batch/Cargo.toml | 1 + crates/ra_batch/src/lib.rs | 20 +++++++++++---- crates/ra_batch/src/vfs_filter.rs | 54 --------------------------------------- 3 files changed, 16 insertions(+), 59 deletions(-) delete mode 100644 crates/ra_batch/src/vfs_filter.rs (limited to 'crates/ra_batch') diff --git a/crates/ra_batch/Cargo.toml b/crates/ra_batch/Cargo.toml index 0ee94c445..8e23826a4 100644 --- a/crates/ra_batch/Cargo.toml +++ b/crates/ra_batch/Cargo.toml @@ -9,6 +9,7 @@ log = "0.4.5" rustc-hash = "1.0" ra_vfs = "0.2.0" +ra_vfs_glob = { path = "../ra_vfs_glob" } ra_db = { path = "../ra_db" } ra_ide_api = { path = "../ra_ide_api" } ra_hir = { path = "../ra_hir" } diff --git a/crates/ra_batch/src/lib.rs b/crates/ra_batch/src/lib.rs index c01574fbc..0db751465 100644 --- a/crates/ra_batch/src/lib.rs +++ b/crates/ra_batch/src/lib.rs @@ -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 = std::result::Result>; @@ -23,7 +21,19 @@ pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap {:?}", path, vfs_file); diff --git a/crates/ra_batch/src/vfs_filter.rs b/crates/ra_batch/src/vfs_filter.rs deleted file mode 100644 index 63bf77704..000000000 --- a/crates/ra_batch/src/vfs_filter.rs +++ /dev/null @@ -1,54 +0,0 @@ -use ra_project_model::PackageRoot; -use ra_vfs::{Filter, RelativePath, RootEntry}; -use std::path::PathBuf; - -/// `IncludeRustFiles` is used to convert -/// from `PackageRoot` to `RootEntry` for VFS -pub struct IncludeRustFiles { - root: PackageRoot, -} - -impl IncludeRustFiles { - pub fn from_roots(roots: R) -> impl Iterator - where - R: IntoIterator, - { - roots.into_iter().map(IncludeRustFiles::from_root) - } - - pub fn from_root(root: PackageRoot) -> RootEntry { - IncludeRustFiles::from(root).into() - } - - #[allow(unused)] - pub fn external(path: PathBuf) -> RootEntry { - IncludeRustFiles::from_root(PackageRoot::new(path, false)) - } - - pub fn member(path: PathBuf) -> RootEntry { - IncludeRustFiles::from_root(PackageRoot::new(path, true)) - } -} - -impl Filter for IncludeRustFiles { - fn include_dir(&self, dir_path: &RelativePath) -> bool { - self.root.include_dir(dir_path) - } - - fn include_file(&self, file_path: &RelativePath) -> bool { - self.root.include_file(file_path) - } -} - -impl From for IncludeRustFiles { - fn from(v: PackageRoot) -> IncludeRustFiles { - IncludeRustFiles { root: v } - } -} - -impl From for RootEntry { - fn from(v: IncludeRustFiles) -> RootEntry { - let path = v.root.path().clone(); - RootEntry::new(path, Box::new(v)) - } -} -- cgit v1.2.3