diff options
author | Aleksey Kladov <[email protected]> | 2019-08-06 12:27:00 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-08-06 13:28:31 +0100 |
commit | 058c2daba1b81804d9f803e57c72f5702c124d9e (patch) | |
tree | 322584a6e4cb2caec3e981dfa7ef8c5a54970762 | |
parent | f70b7e1f079e7b4a51ddd6503860eb97f1a6fcbe (diff) |
push glob errors outwards
-rw-r--r-- | crates/ra_vfs_glob/src/lib.rs | 13 |
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 | ||
8 | use globset::{Glob, GlobSet, GlobSetBuilder}; | 8 | use globset::{GlobSet, GlobSetBuilder}; |
9 | use ra_vfs::{Filter, RelativePath}; | 9 | use ra_vfs::{Filter, RelativePath}; |
10 | 10 | ||
11 | pub use globset::{Glob, GlobBuilder}; | ||
12 | |||
11 | const ALWAYS_IGNORED: &[&str] = &["target/**", "**/node_modules/**", "**/.git/**"]; | 13 | const ALWAYS_IGNORED: &[&str] = &["target/**", "**/node_modules/**", "**/.git/**"]; |
12 | const IGNORED_FOR_NON_MEMBERS: &[&str] = &["examples/**", "tests/**", "benches/**"]; | 14 | const 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"))); |