aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/vfs_filter.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-08-06 12:00:37 +0100
committerAleksey Kladov <[email protected]>2019-08-06 13:28:31 +0100
commit34203256bf8f8ea12b233e0fb49b42bd8c423281 (patch)
tree79ac51baa1696e06955ced637b6132c6a4eabf48 /crates/ra_lsp_server/src/vfs_filter.rs
parentc9718691043b041f5db878caea687b5a029d4475 (diff)
introduce ra_vfs_glob crate
It manages exclusion rules for the vfs crate
Diffstat (limited to 'crates/ra_lsp_server/src/vfs_filter.rs')
-rw-r--r--crates/ra_lsp_server/src/vfs_filter.rs54
1 files changed, 0 insertions, 54 deletions
diff --git a/crates/ra_lsp_server/src/vfs_filter.rs b/crates/ra_lsp_server/src/vfs_filter.rs
deleted file mode 100644
index abdc8dbad..000000000
--- a/crates/ra_lsp_server/src/vfs_filter.rs
+++ /dev/null
@@ -1,54 +0,0 @@
1use ra_project_model::PackageRoot;
2use ra_vfs::{Filter, RelativePath, RootEntry};
3use std::path::PathBuf;
4
5/// `IncludeRustFiles` is used to convert
6/// from `PackageRoot` to `RootEntry` for VFS
7pub struct IncludeRustFiles {
8 root: PackageRoot,
9}
10
11impl IncludeRustFiles {
12 pub fn from_roots<R>(roots: R) -> impl Iterator<Item = RootEntry>
13 where
14 R: IntoIterator<Item = PackageRoot>,
15 {
16 roots.into_iter().map(IncludeRustFiles::from_root)
17 }
18
19 pub fn from_root(root: PackageRoot) -> RootEntry {
20 IncludeRustFiles::from(root).into()
21 }
22
23 #[allow(unused)]
24 pub fn external(path: PathBuf) -> RootEntry {
25 IncludeRustFiles::from_root(PackageRoot::new(path, false))
26 }
27
28 pub fn member(path: PathBuf) -> RootEntry {
29 IncludeRustFiles::from_root(PackageRoot::new(path, true))
30 }
31}
32
33impl Filter for IncludeRustFiles {
34 fn include_dir(&self, dir_path: &RelativePath) -> bool {
35 self.root.include_dir(dir_path)
36 }
37
38 fn include_file(&self, file_path: &RelativePath) -> bool {
39 self.root.include_file(file_path)
40 }
41}
42
43impl std::convert::From<PackageRoot> for IncludeRustFiles {
44 fn from(v: PackageRoot) -> IncludeRustFiles {
45 IncludeRustFiles { root: v }
46 }
47}
48
49impl std::convert::From<IncludeRustFiles> for RootEntry {
50 fn from(v: IncludeRustFiles) -> RootEntry {
51 let path = v.root.path().clone();
52 RootEntry::new(path, Box::new(v))
53 }
54}