aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_vfs_glob/src/lib.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/crates/ra_vfs_glob/src/lib.rs b/crates/ra_vfs_glob/src/lib.rs
index 3e54da5fe..12401d75a 100644
--- a/crates/ra_vfs_glob/src/lib.rs
+++ b/crates/ra_vfs_glob/src/lib.rs
@@ -5,9 +5,11 @@
5//! 5//!
6//! It's also possible to add custom exclusion globs. 6//! It's also possible to add custom exclusion globs.
7 7
8use globset::{Glob, GlobSet, GlobSetBuilder}; 8use globset::{GlobSet, GlobSetBuilder};
9use ra_vfs::{Filter, RelativePath}; 9use ra_vfs::{Filter, RelativePath};
10 10
11pub use globset::{Glob, GlobBuilder};
12
11const ALWAYS_IGNORED: &[&str] = &["target/**", "**/node_modules/**", "**/.git/**"]; 13const ALWAYS_IGNORED: &[&str] = &["target/**", "**/node_modules/**", "**/.git/**"];
12const IGNORED_FOR_NON_MEMBERS: &[&str] = &["examples/**", "tests/**", "benches/**"]; 14const IGNORED_FOR_NON_MEMBERS: &[&str] = &["examples/**", "tests/**", "benches/**"];
13 15
@@ -27,9 +29,9 @@ impl RustPackageFilterBuilder {
27 self.is_member = is_member; 29 self.is_member = is_member;
28 self 30 self
29 } 31 }
30 pub fn exclude(mut self, glob: &str) -> Result<RustPackageFilterBuilder, globset::Error> { 32 pub fn exclude(mut self, glob: Glob) -> RustPackageFilterBuilder {
31 self.exclude.add(Glob::new(glob)?); 33 self.exclude.add(glob);
32 Ok(self) 34 self
33 } 35 }
34 pub fn into_vfs_filter(self) -> Box<dyn Filter> { 36 pub fn into_vfs_filter(self) -> Box<dyn Filter> {
35 let RustPackageFilterBuilder { is_member, mut exclude } = self; 37 let RustPackageFilterBuilder { is_member, mut exclude } = self;
@@ -85,8 +87,7 @@ fn test_globs() {
85 87
86 let filter = RustPackageFilterBuilder::default() 88 let filter = RustPackageFilterBuilder::default()
87 .set_member(true) 89 .set_member(true)
88 .exclude("src/llvm-project/**") 90 .exclude(Glob::new("src/llvm-project/**").unwrap())
89 .unwrap()
90 .into_vfs_filter(); 91 .into_vfs_filter();
91 92
92 assert!(!filter.include_dir(RelativePath::new("src/llvm-project/clang"))); 93 assert!(!filter.include_dir(RelativePath::new("src/llvm-project/clang")));