aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_project_model/src/lib.rs10
-rw-r--r--crates/rust-analyzer/src/cli/analysis_bench.rs4
-rw-r--r--crates/rust-analyzer/src/cli/analysis_stats.rs2
-rw-r--r--crates/rust-analyzer/src/cli/load_cargo.rs15
-rw-r--r--crates/rust-analyzer/src/main_loop.rs7
-rw-r--r--crates/rust-analyzer/src/world.rs2
6 files changed, 25 insertions, 15 deletions
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index ec8574952..0ab64a1e0 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -58,9 +58,9 @@ pub enum ProjectWorkspace {
58#[derive(Clone)] 58#[derive(Clone)]
59pub struct PackageRoot { 59pub struct PackageRoot {
60 /// Path to the root folder 60 /// Path to the root folder
61 pub path: PathBuf, 61 path: PathBuf,
62 /// Is a member of the current workspace 62 /// Is a member of the current workspace
63 pub is_member: bool, 63 is_member: bool,
64} 64}
65impl PackageRoot { 65impl PackageRoot {
66 pub fn new_member(path: PathBuf) -> PackageRoot { 66 pub fn new_member(path: PathBuf) -> PackageRoot {
@@ -69,6 +69,12 @@ impl PackageRoot {
69 pub fn new_non_member(path: PathBuf) -> PackageRoot { 69 pub fn new_non_member(path: PathBuf) -> PackageRoot {
70 Self { path, is_member: false } 70 Self { path, is_member: false }
71 } 71 }
72 pub fn path(&self) -> &Path {
73 &self.path
74 }
75 pub fn is_member(&self) -> bool {
76 self.is_member
77 }
72} 78}
73 79
74impl ProjectWorkspace { 80impl ProjectWorkspace {
diff --git a/crates/rust-analyzer/src/cli/analysis_bench.rs b/crates/rust-analyzer/src/cli/analysis_bench.rs
index 0b138edd7..7667873d5 100644
--- a/crates/rust-analyzer/src/cli/analysis_bench.rs
+++ b/crates/rust-analyzer/src/cli/analysis_bench.rs
@@ -65,10 +65,10 @@ pub fn analysis_bench(
65 roots 65 roots
66 .iter() 66 .iter()
67 .find_map(|(source_root_id, project_root)| { 67 .find_map(|(source_root_id, project_root)| {
68 if project_root.is_member { 68 if project_root.is_member() {
69 for file_id in db.source_root(*source_root_id).walk() { 69 for file_id in db.source_root(*source_root_id).walk() {
70 let rel_path = db.file_relative_path(file_id); 70 let rel_path = db.file_relative_path(file_id);
71 let abs_path = rel_path.to_path(&project_root.path); 71 let abs_path = rel_path.to_path(project_root.path());
72 if abs_path == path { 72 if abs_path == path {
73 return Some(file_id); 73 return Some(file_id);
74 } 74 }
diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs
index edd90df77..75cf2dae5 100644
--- a/crates/rust-analyzer/src/cli/analysis_stats.rs
+++ b/crates/rust-analyzer/src/cli/analysis_stats.rs
@@ -39,7 +39,7 @@ pub fn analysis_stats(
39 roots 39 roots
40 .into_iter() 40 .into_iter()
41 .filter_map(|(source_root_id, project_root)| { 41 .filter_map(|(source_root_id, project_root)| {
42 if with_deps || project_root.is_member { 42 if with_deps || project_root.is_member() {
43 Some(source_root_id) 43 Some(source_root_id)
44 } else { 44 } else {
45 None 45 None
diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs
index 109b1d74b..69133e4e4 100644
--- a/crates/rust-analyzer/src/cli/load_cargo.rs
+++ b/crates/rust-analyzer/src/cli/load_cargo.rs
@@ -45,9 +45,9 @@ pub(crate) fn load_cargo(
45 .iter() 45 .iter()
46 .map(|pkg_root| { 46 .map(|pkg_root| {
47 RootEntry::new( 47 RootEntry::new(
48 pkg_root.path.clone(), 48 pkg_root.path().to_owned(),
49 RustPackageFilterBuilder::default() 49 RustPackageFilterBuilder::default()
50 .set_member(pkg_root.is_member) 50 .set_member(pkg_root.is_member())
51 .into_vfs_filter(), 51 .into_vfs_filter(),
52 ) 52 )
53 }) 53 })
@@ -60,8 +60,11 @@ pub(crate) fn load_cargo(
60 .into_iter() 60 .into_iter()
61 .map(|vfs_root| { 61 .map(|vfs_root| {
62 let source_root_id = vfs_root_to_id(vfs_root); 62 let source_root_id = vfs_root_to_id(vfs_root);
63 let project_root = 63 let project_root = project_roots
64 project_roots.iter().find(|it| it.path == vfs.root2path(vfs_root)).unwrap().clone(); 64 .iter()
65 .find(|it| it.path() == vfs.root2path(vfs_root))
66 .unwrap()
67 .clone();
65 (source_root_id, project_root) 68 (source_root_id, project_root)
66 }) 69 })
67 .collect::<FxHashMap<_, _>>(); 70 .collect::<FxHashMap<_, _>>();
@@ -93,7 +96,7 @@ pub(crate) fn load(
93 match change { 96 match change {
94 VfsChange::AddRoot { root, files } => { 97 VfsChange::AddRoot { root, files } => {
95 let source_root_id = vfs_root_to_id(root); 98 let source_root_id = vfs_root_to_id(root);
96 let is_local = source_roots[&source_root_id].is_member; 99 let is_local = source_roots[&source_root_id].is_member();
97 log::debug!( 100 log::debug!(
98 "loaded source root {:?} with path {:?}", 101 "loaded source root {:?} with path {:?}",
99 source_root_id, 102 source_root_id,
@@ -102,7 +105,7 @@ pub(crate) fn load(
102 analysis_change.add_root(source_root_id, is_local); 105 analysis_change.add_root(source_root_id, is_local);
103 analysis_change.set_debug_root_path( 106 analysis_change.set_debug_root_path(
104 source_root_id, 107 source_root_id,
105 source_roots[&source_root_id].path.display().to_string(), 108 source_roots[&source_root_id].path().display().to_string(),
106 ); 109 );
107 110
108 let vfs_root_path = vfs.root2path(root); 111 let vfs_root_path = vfs.root2path(root);
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index e61a56935..8d1429196 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -23,6 +23,7 @@ use lsp_types::{
23use ra_flycheck::{url_from_path_with_drive_lowercasing, CheckTask}; 23use ra_flycheck::{url_from_path_with_drive_lowercasing, CheckTask};
24use ra_ide::{Canceled, FileId, LibraryData, SourceRootId}; 24use ra_ide::{Canceled, FileId, LibraryData, SourceRootId};
25use ra_prof::profile; 25use ra_prof::profile;
26use ra_project_model::{PackageRoot, ProjectWorkspace};
26use ra_vfs::{VfsFile, VfsTask, Watch}; 27use ra_vfs::{VfsFile, VfsTask, Watch};
27use relative_path::RelativePathBuf; 28use relative_path::RelativePathBuf;
28use rustc_hash::FxHashSet; 29use rustc_hash::FxHashSet;
@@ -131,9 +132,9 @@ pub fn main_loop(ws_roots: Vec<PathBuf>, config: Config, connection: Connection)
131 let registration_options = req::DidChangeWatchedFilesRegistrationOptions { 132 let registration_options = req::DidChangeWatchedFilesRegistrationOptions {
132 watchers: workspaces 133 watchers: workspaces
133 .iter() 134 .iter()
134 .flat_map(|ws| ws.to_roots()) 135 .flat_map(ProjectWorkspace::to_roots)
135 .filter(|root| root.is_member) 136 .filter(PackageRoot::is_member)
136 .map(|root| format!("{}/**/*.rs", root.path.display())) 137 .map(|root| format!("{}/**/*.rs", root.path().display()))
137 .map(|glob_pattern| req::FileSystemWatcher { glob_pattern, kind: None }) 138 .map(|glob_pattern| req::FileSystemWatcher { glob_pattern, kind: None })
138 .collect(), 139 .collect(),
139 }; 140 };
diff --git a/crates/rust-analyzer/src/world.rs b/crates/rust-analyzer/src/world.rs
index a6549a8f4..3be4455e3 100644
--- a/crates/rust-analyzer/src/world.rs
+++ b/crates/rust-analyzer/src/world.rs
@@ -101,7 +101,7 @@ impl WorldState {
101 .iter() 101 .iter()
102 .map(|path| RootEntry::new(path.clone(), create_filter(true))) 102 .map(|path| RootEntry::new(path.clone(), create_filter(true)))
103 .chain(workspaces.iter().flat_map(ProjectWorkspace::to_roots).map(|pkg_root| { 103 .chain(workspaces.iter().flat_map(ProjectWorkspace::to_roots).map(|pkg_root| {
104 RootEntry::new(pkg_root.path, create_filter(pkg_root.is_member)) 104 RootEntry::new(pkg_root.path().to_owned(), create_filter(pkg_root.is_member()))
105 })) 105 }))
106 .chain( 106 .chain(
107 extern_dirs 107 extern_dirs