diff options
-rw-r--r-- | crates/ra_batch/src/lib.rs | 6 | ||||
-rw-r--r-- | crates/ra_batch/src/vfs_filter.rs | 18 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/vfs_filter.rs | 18 | ||||
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 20 |
4 files changed, 31 insertions, 31 deletions
diff --git a/crates/ra_batch/src/lib.rs b/crates/ra_batch/src/lib.rs index c25737aaa..c01574fbc 100644 --- a/crates/ra_batch/src/lib.rs +++ b/crates/ra_batch/src/lib.rs | |||
@@ -6,7 +6,7 @@ use rustc_hash::FxHashMap; | |||
6 | 6 | ||
7 | use ra_db::{CrateGraph, FileId, SourceRootId}; | 7 | use ra_db::{CrateGraph, FileId, SourceRootId}; |
8 | use ra_ide_api::{AnalysisChange, AnalysisHost}; | 8 | use ra_ide_api::{AnalysisChange, AnalysisHost}; |
9 | use ra_project_model::{ProjectRoot, ProjectWorkspace}; | 9 | use ra_project_model::{PackageRoot, ProjectWorkspace}; |
10 | use ra_vfs::{Vfs, VfsChange}; | 10 | use ra_vfs::{Vfs, VfsChange}; |
11 | use vfs_filter::IncludeRustFiles; | 11 | use vfs_filter::IncludeRustFiles; |
12 | 12 | ||
@@ -19,7 +19,7 @@ fn vfs_root_to_id(r: ra_vfs::VfsRoot) -> SourceRootId { | |||
19 | SourceRootId(r.0) | 19 | SourceRootId(r.0) |
20 | } | 20 | } |
21 | 21 | ||
22 | pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap<SourceRootId, ProjectRoot>)> { | 22 | pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap<SourceRootId, PackageRoot>)> { |
23 | let root = std::env::current_dir()?.join(root); | 23 | let root = std::env::current_dir()?.join(root); |
24 | let ws = ProjectWorkspace::discover(root.as_ref())?; | 24 | let ws = ProjectWorkspace::discover(root.as_ref())?; |
25 | let project_roots = ws.to_roots(); | 25 | let project_roots = ws.to_roots(); |
@@ -48,7 +48,7 @@ pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap<SourceRootId, | |||
48 | } | 48 | } |
49 | 49 | ||
50 | pub fn load( | 50 | pub fn load( |
51 | source_roots: &FxHashMap<SourceRootId, ProjectRoot>, | 51 | source_roots: &FxHashMap<SourceRootId, PackageRoot>, |
52 | crate_graph: CrateGraph, | 52 | crate_graph: CrateGraph, |
53 | vfs: &mut Vfs, | 53 | vfs: &mut Vfs, |
54 | ) -> AnalysisHost { | 54 | ) -> AnalysisHost { |
diff --git a/crates/ra_batch/src/vfs_filter.rs b/crates/ra_batch/src/vfs_filter.rs index 2f0d8cb8b..63bf77704 100644 --- a/crates/ra_batch/src/vfs_filter.rs +++ b/crates/ra_batch/src/vfs_filter.rs | |||
@@ -1,32 +1,32 @@ | |||
1 | use ra_project_model::ProjectRoot; | 1 | use ra_project_model::PackageRoot; |
2 | use ra_vfs::{Filter, RelativePath, RootEntry}; | 2 | use ra_vfs::{Filter, RelativePath, RootEntry}; |
3 | use std::path::PathBuf; | 3 | use std::path::PathBuf; |
4 | 4 | ||
5 | /// `IncludeRustFiles` is used to convert | 5 | /// `IncludeRustFiles` is used to convert |
6 | /// from `ProjectRoot` to `RootEntry` for VFS | 6 | /// from `PackageRoot` to `RootEntry` for VFS |
7 | pub struct IncludeRustFiles { | 7 | pub struct IncludeRustFiles { |
8 | root: ProjectRoot, | 8 | root: PackageRoot, |
9 | } | 9 | } |
10 | 10 | ||
11 | impl IncludeRustFiles { | 11 | impl IncludeRustFiles { |
12 | pub fn from_roots<R>(roots: R) -> impl Iterator<Item = RootEntry> | 12 | pub fn from_roots<R>(roots: R) -> impl Iterator<Item = RootEntry> |
13 | where | 13 | where |
14 | R: IntoIterator<Item = ProjectRoot>, | 14 | R: IntoIterator<Item = PackageRoot>, |
15 | { | 15 | { |
16 | roots.into_iter().map(IncludeRustFiles::from_root) | 16 | roots.into_iter().map(IncludeRustFiles::from_root) |
17 | } | 17 | } |
18 | 18 | ||
19 | pub fn from_root(root: ProjectRoot) -> RootEntry { | 19 | pub fn from_root(root: PackageRoot) -> RootEntry { |
20 | IncludeRustFiles::from(root).into() | 20 | IncludeRustFiles::from(root).into() |
21 | } | 21 | } |
22 | 22 | ||
23 | #[allow(unused)] | 23 | #[allow(unused)] |
24 | pub fn external(path: PathBuf) -> RootEntry { | 24 | pub fn external(path: PathBuf) -> RootEntry { |
25 | IncludeRustFiles::from_root(ProjectRoot::new(path, false)) | 25 | IncludeRustFiles::from_root(PackageRoot::new(path, false)) |
26 | } | 26 | } |
27 | 27 | ||
28 | pub fn member(path: PathBuf) -> RootEntry { | 28 | pub fn member(path: PathBuf) -> RootEntry { |
29 | IncludeRustFiles::from_root(ProjectRoot::new(path, true)) | 29 | IncludeRustFiles::from_root(PackageRoot::new(path, true)) |
30 | } | 30 | } |
31 | } | 31 | } |
32 | 32 | ||
@@ -40,8 +40,8 @@ impl Filter for IncludeRustFiles { | |||
40 | } | 40 | } |
41 | } | 41 | } |
42 | 42 | ||
43 | impl From<ProjectRoot> for IncludeRustFiles { | 43 | impl From<PackageRoot> for IncludeRustFiles { |
44 | fn from(v: ProjectRoot) -> IncludeRustFiles { | 44 | fn from(v: PackageRoot) -> IncludeRustFiles { |
45 | IncludeRustFiles { root: v } | 45 | IncludeRustFiles { root: v } |
46 | } | 46 | } |
47 | } | 47 | } |
diff --git a/crates/ra_lsp_server/src/vfs_filter.rs b/crates/ra_lsp_server/src/vfs_filter.rs index e16a57da5..abdc8dbad 100644 --- a/crates/ra_lsp_server/src/vfs_filter.rs +++ b/crates/ra_lsp_server/src/vfs_filter.rs | |||
@@ -1,32 +1,32 @@ | |||
1 | use ra_project_model::ProjectRoot; | 1 | use ra_project_model::PackageRoot; |
2 | use ra_vfs::{Filter, RelativePath, RootEntry}; | 2 | use ra_vfs::{Filter, RelativePath, RootEntry}; |
3 | use std::path::PathBuf; | 3 | use std::path::PathBuf; |
4 | 4 | ||
5 | /// `IncludeRustFiles` is used to convert | 5 | /// `IncludeRustFiles` is used to convert |
6 | /// from `ProjectRoot` to `RootEntry` for VFS | 6 | /// from `PackageRoot` to `RootEntry` for VFS |
7 | pub struct IncludeRustFiles { | 7 | pub struct IncludeRustFiles { |
8 | root: ProjectRoot, | 8 | root: PackageRoot, |
9 | } | 9 | } |
10 | 10 | ||
11 | impl IncludeRustFiles { | 11 | impl IncludeRustFiles { |
12 | pub fn from_roots<R>(roots: R) -> impl Iterator<Item = RootEntry> | 12 | pub fn from_roots<R>(roots: R) -> impl Iterator<Item = RootEntry> |
13 | where | 13 | where |
14 | R: IntoIterator<Item = ProjectRoot>, | 14 | R: IntoIterator<Item = PackageRoot>, |
15 | { | 15 | { |
16 | roots.into_iter().map(IncludeRustFiles::from_root) | 16 | roots.into_iter().map(IncludeRustFiles::from_root) |
17 | } | 17 | } |
18 | 18 | ||
19 | pub fn from_root(root: ProjectRoot) -> RootEntry { | 19 | pub fn from_root(root: PackageRoot) -> RootEntry { |
20 | IncludeRustFiles::from(root).into() | 20 | IncludeRustFiles::from(root).into() |
21 | } | 21 | } |
22 | 22 | ||
23 | #[allow(unused)] | 23 | #[allow(unused)] |
24 | pub fn external(path: PathBuf) -> RootEntry { | 24 | pub fn external(path: PathBuf) -> RootEntry { |
25 | IncludeRustFiles::from_root(ProjectRoot::new(path, false)) | 25 | IncludeRustFiles::from_root(PackageRoot::new(path, false)) |
26 | } | 26 | } |
27 | 27 | ||
28 | pub fn member(path: PathBuf) -> RootEntry { | 28 | pub fn member(path: PathBuf) -> RootEntry { |
29 | IncludeRustFiles::from_root(ProjectRoot::new(path, true)) | 29 | IncludeRustFiles::from_root(PackageRoot::new(path, true)) |
30 | } | 30 | } |
31 | } | 31 | } |
32 | 32 | ||
@@ -40,8 +40,8 @@ impl Filter for IncludeRustFiles { | |||
40 | } | 40 | } |
41 | } | 41 | } |
42 | 42 | ||
43 | impl std::convert::From<ProjectRoot> for IncludeRustFiles { | 43 | impl std::convert::From<PackageRoot> for IncludeRustFiles { |
44 | fn from(v: ProjectRoot) -> IncludeRustFiles { | 44 | fn from(v: PackageRoot) -> IncludeRustFiles { |
45 | IncludeRustFiles { root: v } | 45 | IncludeRustFiles { root: v } |
46 | } | 46 | } |
47 | } | 47 | } |
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index 08e5c1c32..647a1f365 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs | |||
@@ -34,20 +34,20 @@ pub enum ProjectWorkspace { | |||
34 | Json { project: JsonProject }, | 34 | Json { project: JsonProject }, |
35 | } | 35 | } |
36 | 36 | ||
37 | /// `ProjectRoot` describes a workspace root folder. | 37 | /// `PackageRoot` describes a package root folder. |
38 | /// Which may be an external dependency, or a member of | 38 | /// Which may be an external dependency, or a member of |
39 | /// the current workspace. | 39 | /// the current workspace. |
40 | #[derive(Clone)] | 40 | #[derive(Clone)] |
41 | pub struct ProjectRoot { | 41 | pub struct PackageRoot { |
42 | /// Path to the root folder | 42 | /// Path to the root folder |
43 | path: PathBuf, | 43 | path: PathBuf, |
44 | /// Is a member of the current workspace | 44 | /// Is a member of the current workspace |
45 | is_member: bool, | 45 | is_member: bool, |
46 | } | 46 | } |
47 | 47 | ||
48 | impl ProjectRoot { | 48 | impl PackageRoot { |
49 | pub fn new(path: PathBuf, is_member: bool) -> ProjectRoot { | 49 | pub fn new(path: PathBuf, is_member: bool) -> PackageRoot { |
50 | ProjectRoot { path, is_member } | 50 | PackageRoot { path, is_member } |
51 | } | 51 | } |
52 | 52 | ||
53 | pub fn path(&self) -> &PathBuf { | 53 | pub fn path(&self) -> &PathBuf { |
@@ -99,15 +99,15 @@ impl ProjectWorkspace { | |||
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | /// Returns the roots for the current ProjectWorkspace | 102 | /// Returns the roots for the current `ProjectWorkspace` |
103 | /// The return type contains the path and whether or not | 103 | /// The return type contains the path and whether or not |
104 | /// the root is a member of the current workspace | 104 | /// the root is a member of the current workspace |
105 | pub fn to_roots(&self) -> Vec<ProjectRoot> { | 105 | pub fn to_roots(&self) -> Vec<PackageRoot> { |
106 | match self { | 106 | match self { |
107 | ProjectWorkspace::Json { project } => { | 107 | ProjectWorkspace::Json { project } => { |
108 | let mut roots = Vec::with_capacity(project.roots.len()); | 108 | let mut roots = Vec::with_capacity(project.roots.len()); |
109 | for root in &project.roots { | 109 | for root in &project.roots { |
110 | roots.push(ProjectRoot::new(root.path.clone(), true)); | 110 | roots.push(PackageRoot::new(root.path.clone(), true)); |
111 | } | 111 | } |
112 | roots | 112 | roots |
113 | } | 113 | } |
@@ -117,10 +117,10 @@ impl ProjectWorkspace { | |||
117 | for pkg in cargo.packages() { | 117 | for pkg in cargo.packages() { |
118 | let root = pkg.root(&cargo).to_path_buf(); | 118 | let root = pkg.root(&cargo).to_path_buf(); |
119 | let member = pkg.is_member(&cargo); | 119 | let member = pkg.is_member(&cargo); |
120 | roots.push(ProjectRoot::new(root, member)); | 120 | roots.push(PackageRoot::new(root, member)); |
121 | } | 121 | } |
122 | for krate in sysroot.crates() { | 122 | for krate in sysroot.crates() { |
123 | roots.push(ProjectRoot::new(krate.root_dir(&sysroot).to_path_buf(), false)) | 123 | roots.push(PackageRoot::new(krate.root_dir(&sysroot).to_path_buf(), false)) |
124 | } | 124 | } |
125 | roots | 125 | roots |
126 | } | 126 | } |