aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/main_loop.rs1
-rw-r--r--crates/rust-analyzer/src/world.rs24
2 files changed, 14 insertions, 11 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index f1287d52c..2e5499485 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -164,7 +164,6 @@ pub fn main_loop(ws_roots: Vec<PathBuf>, config: Config, connection: Connection)
164 } 164 }
165 165
166 WorldState::new( 166 WorldState::new(
167 ws_roots,
168 workspaces, 167 workspaces,
169 config.lru_capacity, 168 config.lru_capacity,
170 &globs, 169 &globs,
diff --git a/crates/rust-analyzer/src/world.rs b/crates/rust-analyzer/src/world.rs
index 367272925..c1010e86a 100644
--- a/crates/rust-analyzer/src/world.rs
+++ b/crates/rust-analyzer/src/world.rs
@@ -58,7 +58,7 @@ fn create_flycheck(workspaces: &[ProjectWorkspace], config: &FlycheckConfig) ->
58#[derive(Debug)] 58#[derive(Debug)]
59pub struct WorldState { 59pub struct WorldState {
60 pub config: Config, 60 pub config: Config,
61 pub roots: Vec<PathBuf>, 61 pub local_roots: Vec<PathBuf>,
62 pub workspaces: Arc<Vec<ProjectWorkspace>>, 62 pub workspaces: Arc<Vec<ProjectWorkspace>>,
63 pub analysis_host: AnalysisHost, 63 pub analysis_host: AnalysisHost,
64 pub vfs: Arc<RwLock<Vfs>>, 64 pub vfs: Arc<RwLock<Vfs>>,
@@ -81,7 +81,6 @@ pub struct WorldSnapshot {
81 81
82impl WorldState { 82impl WorldState {
83 pub fn new( 83 pub fn new(
84 folder_roots: Vec<PathBuf>,
85 workspaces: Vec<ProjectWorkspace>, 84 workspaces: Vec<ProjectWorkspace>,
86 lru_capacity: Option<usize>, 85 lru_capacity: Option<usize>,
87 exclude_globs: &[Glob], 86 exclude_globs: &[Glob],
@@ -93,6 +92,7 @@ impl WorldState {
93 let extern_dirs: FxHashSet<_> = 92 let extern_dirs: FxHashSet<_> =
94 workspaces.iter().flat_map(ProjectWorkspace::out_dirs).collect(); 93 workspaces.iter().flat_map(ProjectWorkspace::out_dirs).collect();
95 94
95 let mut local_roots = Vec::new();
96 let roots: Vec<_> = { 96 let roots: Vec<_> = {
97 let create_filter = |is_member| { 97 let create_filter = |is_member| {
98 RustPackageFilterBuilder::default() 98 RustPackageFilterBuilder::default()
@@ -100,12 +100,16 @@ impl WorldState {
100 .exclude(exclude_globs.iter().cloned()) 100 .exclude(exclude_globs.iter().cloned())
101 .into_vfs_filter() 101 .into_vfs_filter()
102 }; 102 };
103 folder_roots 103 workspaces
104 .iter() 104 .iter()
105 .map(|path| RootEntry::new(path.clone(), create_filter(true))) 105 .flat_map(ProjectWorkspace::to_roots)
106 .chain(workspaces.iter().flat_map(ProjectWorkspace::to_roots).map(|pkg_root| { 106 .map(|pkg_root| {
107 RootEntry::new(pkg_root.path().to_owned(), create_filter(pkg_root.is_member())) 107 let path = pkg_root.path().to_owned();
108 })) 108 if pkg_root.is_member() {
109 local_roots.push(path.clone());
110 }
111 RootEntry::new(path, create_filter(pkg_root.is_member()))
112 })
109 .chain( 113 .chain(
110 extern_dirs 114 extern_dirs
111 .iter() 115 .iter()
@@ -121,7 +125,7 @@ impl WorldState {
121 let mut extern_source_roots = FxHashMap::default(); 125 let mut extern_source_roots = FxHashMap::default();
122 for r in vfs_roots { 126 for r in vfs_roots {
123 let vfs_root_path = vfs.root2path(r); 127 let vfs_root_path = vfs.root2path(r);
124 let is_local = folder_roots.iter().any(|it| vfs_root_path.starts_with(it)); 128 let is_local = local_roots.iter().any(|it| vfs_root_path.starts_with(it));
125 change.add_root(SourceRootId(r.0), is_local); 129 change.add_root(SourceRootId(r.0), is_local);
126 change.set_debug_root_path(SourceRootId(r.0), vfs_root_path.display().to_string()); 130 change.set_debug_root_path(SourceRootId(r.0), vfs_root_path.display().to_string());
127 131
@@ -178,7 +182,7 @@ impl WorldState {
178 analysis_host.apply_change(change); 182 analysis_host.apply_change(change);
179 WorldState { 183 WorldState {
180 config, 184 config,
181 roots: folder_roots, 185 local_roots,
182 workspaces: Arc::new(workspaces), 186 workspaces: Arc::new(workspaces),
183 analysis_host, 187 analysis_host,
184 vfs: Arc::new(RwLock::new(vfs)), 188 vfs: Arc::new(RwLock::new(vfs)),
@@ -216,7 +220,7 @@ impl WorldState {
216 match c { 220 match c {
217 VfsChange::AddRoot { root, files } => { 221 VfsChange::AddRoot { root, files } => {
218 let root_path = self.vfs.read().root2path(root); 222 let root_path = self.vfs.read().root2path(root);
219 let is_local = self.roots.iter().any(|r| root_path.starts_with(r)); 223 let is_local = self.local_roots.iter().any(|r| root_path.starts_with(r));
220 if is_local { 224 if is_local {
221 *roots_scanned += 1; 225 *roots_scanned += 1;
222 for (file, path, text) in files { 226 for (file, path, text) in files {