aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock8
-rw-r--r--crates/ra_batch/Cargo.toml2
-rw-r--r--crates/ra_batch/src/lib.rs29
-rw-r--r--crates/ra_lsp_server/Cargo.toml2
-rw-r--r--crates/ra_lsp_server/src/server_world.rs30
5 files changed, 61 insertions, 10 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 6f4c4f767..ad9f6970b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -928,7 +928,7 @@ dependencies = [
928 "ra_hir 0.1.0", 928 "ra_hir 0.1.0",
929 "ra_project_model 0.1.0", 929 "ra_project_model 0.1.0",
930 "ra_syntax 0.1.0", 930 "ra_syntax 0.1.0",
931 "ra_vfs 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 931 "ra_vfs 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
932 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 932 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
933 "test_utils 0.1.0", 933 "test_utils 0.1.0",
934] 934]
@@ -1050,7 +1050,7 @@ dependencies = [
1050 "ra_project_model 0.1.0", 1050 "ra_project_model 0.1.0",
1051 "ra_syntax 0.1.0", 1051 "ra_syntax 0.1.0",
1052 "ra_text_edit 0.1.0", 1052 "ra_text_edit 0.1.0",
1053 "ra_vfs 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 1053 "ra_vfs 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
1054 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 1054 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
1055 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 1055 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
1056 "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", 1056 "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1131,7 +1131,7 @@ dependencies = [
1131 1131
1132[[package]] 1132[[package]]
1133name = "ra_vfs" 1133name = "ra_vfs"
1134version = "0.1.1" 1134version = "0.2.0"
1135source = "registry+https://github.com/rust-lang/crates.io-index" 1135source = "registry+https://github.com/rust-lang/crates.io-index"
1136dependencies = [ 1136dependencies = [
1137 "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 1137 "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1996,7 +1996,7 @@ dependencies = [
1996"checksum proptest 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea66c78d75f2c6e9f304269eaef90899798daecc69f1a625d5a3dd793ff3522" 1996"checksum proptest 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea66c78d75f2c6e9f304269eaef90899798daecc69f1a625d5a3dd793ff3522"
1997"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" 1997"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
1998"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" 1998"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1"
1999"checksum ra_vfs 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5978b0ced52f013ce44bfca6ac903141359e7cc3baea462a4a670de9e5087101" 1999"checksum ra_vfs 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1839e4e003d865b58b8b6c231aae6c463dfcd01bfbbddffbdb7662a7b5a627"
2000"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" 2000"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
2001"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" 2001"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
2002"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" 2002"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
diff --git a/crates/ra_batch/Cargo.toml b/crates/ra_batch/Cargo.toml
index 5b78cb76e..3037e27c4 100644
--- a/crates/ra_batch/Cargo.toml
+++ b/crates/ra_batch/Cargo.toml
@@ -10,7 +10,7 @@ rustc-hash = "1.0"
10 10
11failure = "0.1.4" 11failure = "0.1.4"
12 12
13ra_vfs = "0.1.0" 13ra_vfs = "0.2.0"
14ra_syntax = { path = "../ra_syntax" } 14ra_syntax = { path = "../ra_syntax" }
15ra_db = { path = "../ra_db" } 15ra_db = { path = "../ra_db" }
16ra_hir = { path = "../ra_hir" } 16ra_hir = { path = "../ra_hir" }
diff --git a/crates/ra_batch/src/lib.rs b/crates/ra_batch/src/lib.rs
index c6d10107d..a054d0da3 100644
--- a/crates/ra_batch/src/lib.rs
+++ b/crates/ra_batch/src/lib.rs
@@ -1,5 +1,5 @@
1use std::sync::Arc; 1use std::sync::Arc;
2use std::path::Path; 2use std::path::{Path, PathBuf};
3use std::collections::HashSet; 3use std::collections::HashSet;
4 4
5use rustc_hash::FxHashMap; 5use rustc_hash::FxHashMap;
@@ -9,7 +9,7 @@ use ra_db::{
9}; 9};
10use ra_hir::{db, HirInterner}; 10use ra_hir::{db, HirInterner};
11use ra_project_model::ProjectWorkspace; 11use ra_project_model::ProjectWorkspace;
12use ra_vfs::{Vfs, VfsChange}; 12use ra_vfs::{Vfs, VfsChange, RootEntry, Filter, RelativePath};
13 13
14type Result<T> = std::result::Result<T, failure::Error>; 14type Result<T> = std::result::Result<T, failure::Error>;
15 15
@@ -43,6 +43,30 @@ fn vfs_root_to_id(r: ra_vfs::VfsRoot) -> SourceRootId {
43 SourceRootId(r.0.into()) 43 SourceRootId(r.0.into())
44} 44}
45 45
46struct IncludeRustFiles;
47
48impl IncludeRustFiles {
49 fn to_entry(path: PathBuf) -> RootEntry {
50 RootEntry::new(path, Box::new(Self {}))
51 }
52}
53
54impl Filter for IncludeRustFiles {
55 fn include_dir(&self, dir_path: &RelativePath) -> bool {
56 const IGNORED_FOLDERS: &[&str] = &["node_modules", "target", ".git"];
57
58 let is_ignored = dir_path.components().any(|c| IGNORED_FOLDERS.contains(&c.as_str()));
59
60 let hidden = dir_path.components().any(|c| c.as_str().starts_with("."));
61
62 !is_ignored && !hidden
63 }
64
65 fn include_file(&self, file_path: &RelativePath) -> bool {
66 file_path.extension() == Some("rs")
67 }
68}
69
46impl BatchDatabase { 70impl BatchDatabase {
47 pub fn load(crate_graph: CrateGraph, vfs: &mut Vfs) -> BatchDatabase { 71 pub fn load(crate_graph: CrateGraph, vfs: &mut Vfs) -> BatchDatabase {
48 let mut db = 72 let mut db =
@@ -100,6 +124,7 @@ impl BatchDatabase {
100 let mut roots = Vec::new(); 124 let mut roots = Vec::new();
101 roots.push(root.clone()); 125 roots.push(root.clone());
102 roots.extend(ws.to_roots()); 126 roots.extend(ws.to_roots());
127 let roots = roots.into_iter().map(IncludeRustFiles::to_entry).collect::<Vec<_>>();
103 let (mut vfs, roots) = Vfs::new(roots); 128 let (mut vfs, roots) = Vfs::new(roots);
104 let mut load = |path: &Path| { 129 let mut load = |path: &Path| {
105 let vfs_file = vfs.load(path); 130 let vfs_file = vfs.load(path);
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml
index 2b3890e01..d82410700 100644
--- a/crates/ra_lsp_server/Cargo.toml
+++ b/crates/ra_lsp_server/Cargo.toml
@@ -19,7 +19,7 @@ lsp-types = "0.56.0"
19rustc-hash = "1.0" 19rustc-hash = "1.0"
20parking_lot = "0.7.0" 20parking_lot = "0.7.0"
21 21
22ra_vfs = "0.1.0" 22ra_vfs = "0.2.0"
23thread_worker = { path = "../thread_worker" } 23thread_worker = { path = "../thread_worker" }
24ra_syntax = { path = "../ra_syntax" } 24ra_syntax = { path = "../ra_syntax" }
25ra_text_edit = { path = "../ra_text_edit" } 25ra_text_edit = { path = "../ra_text_edit" }
diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs
index 7163568b9..cf7c17c5c 100644
--- a/crates/ra_lsp_server/src/server_world.rs
+++ b/crates/ra_lsp_server/src/server_world.rs
@@ -8,8 +8,8 @@ use ra_ide_api::{
8 Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, LibraryData, 8 Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, LibraryData,
9 SourceRootId 9 SourceRootId
10}; 10};
11use ra_vfs::{Vfs, VfsChange, VfsFile, VfsRoot}; 11use ra_vfs::{Vfs, VfsChange, VfsFile, VfsRoot, RootEntry, Filter};
12use relative_path::RelativePathBuf; 12use relative_path::{RelativePath, RelativePathBuf};
13use parking_lot::RwLock; 13use parking_lot::RwLock;
14use failure::format_err; 14use failure::format_err;
15 15
@@ -33,6 +33,30 @@ pub struct ServerWorld {
33 pub vfs: Arc<RwLock<Vfs>>, 33 pub vfs: Arc<RwLock<Vfs>>,
34} 34}
35 35
36struct IncludeRustFiles;
37
38impl IncludeRustFiles {
39 fn to_entry(path: PathBuf) -> RootEntry {
40 RootEntry::new(path, Box::new(Self {}))
41 }
42}
43
44impl Filter for IncludeRustFiles {
45 fn include_dir(&self, dir_path: &RelativePath) -> bool {
46 const IGNORED_FOLDERS: &[&str] = &["node_modules", "target", ".git"];
47
48 let is_ignored = dir_path.components().any(|c| IGNORED_FOLDERS.contains(&c.as_str()));
49
50 let hidden = dir_path.components().any(|c| c.as_str().starts_with("."));
51
52 !is_ignored && !hidden
53 }
54
55 fn include_file(&self, file_path: &RelativePath) -> bool {
56 file_path.extension() == Some("rs")
57 }
58}
59
36impl ServerWorldState { 60impl ServerWorldState {
37 pub fn new(root: PathBuf, workspaces: Vec<ProjectWorkspace>) -> ServerWorldState { 61 pub fn new(root: PathBuf, workspaces: Vec<ProjectWorkspace>) -> ServerWorldState {
38 let mut change = AnalysisChange::new(); 62 let mut change = AnalysisChange::new();
@@ -42,6 +66,8 @@ impl ServerWorldState {
42 for ws in workspaces.iter() { 66 for ws in workspaces.iter() {
43 roots.extend(ws.to_roots()); 67 roots.extend(ws.to_roots());
44 } 68 }
69 let roots = roots.into_iter().map(IncludeRustFiles::to_entry).collect::<Vec<_>>();
70
45 let (mut vfs, roots) = Vfs::new(roots); 71 let (mut vfs, roots) = Vfs::new(roots);
46 let roots_to_scan = roots.len(); 72 let roots_to_scan = roots.len();
47 for r in roots { 73 for r in roots {