aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-06-03 11:05:50 +0100
committerAleksey Kladov <[email protected]>2020-06-03 11:05:50 +0100
commit03a76191a18b450a8e4ae309296fd7c0614d14d2 (patch)
treebcc25e58278379aff447e9d8f3ce5c5402649e6b /crates
parent0a88de809f13f3b4abe0ffa11ff87c6f845050bd (diff)
Rename ProjectRoot -> ProjectManifest
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_project_model/src/lib.rs30
-rw-r--r--crates/rust-analyzer/src/cli/load_cargo.rs4
-rw-r--r--crates/rust-analyzer/src/main_loop.rs4
3 files changed, 19 insertions, 19 deletions
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index d5f82f17a..a99612690 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -58,24 +58,24 @@ impl PackageRoot {
58} 58}
59 59
60#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)] 60#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)]
61pub enum ProjectRoot { 61pub enum ProjectManifest {
62 ProjectJson(PathBuf), 62 ProjectJson(PathBuf),
63 CargoToml(PathBuf), 63 CargoToml(PathBuf),
64} 64}
65 65
66impl ProjectRoot { 66impl ProjectManifest {
67 pub fn from_manifest_file(path: PathBuf) -> Result<ProjectRoot> { 67 pub fn from_manifest_file(path: PathBuf) -> Result<ProjectManifest> {
68 if path.ends_with("rust-project.json") { 68 if path.ends_with("rust-project.json") {
69 return Ok(ProjectRoot::ProjectJson(path)); 69 return Ok(ProjectManifest::ProjectJson(path));
70 } 70 }
71 if path.ends_with("Cargo.toml") { 71 if path.ends_with("Cargo.toml") {
72 return Ok(ProjectRoot::CargoToml(path)); 72 return Ok(ProjectManifest::CargoToml(path));
73 } 73 }
74 bail!("project root must point to Cargo.toml or rust-project.json: {}", path.display()) 74 bail!("project root must point to Cargo.toml or rust-project.json: {}", path.display())
75 } 75 }
76 76
77 pub fn discover_single(path: &Path) -> Result<ProjectRoot> { 77 pub fn discover_single(path: &Path) -> Result<ProjectManifest> {
78 let mut candidates = ProjectRoot::discover(path)?; 78 let mut candidates = ProjectManifest::discover(path)?;
79 let res = match candidates.pop() { 79 let res = match candidates.pop() {
80 None => bail!("no projects"), 80 None => bail!("no projects"),
81 Some(it) => it, 81 Some(it) => it,
@@ -87,12 +87,12 @@ impl ProjectRoot {
87 Ok(res) 87 Ok(res)
88 } 88 }
89 89
90 pub fn discover(path: &Path) -> io::Result<Vec<ProjectRoot>> { 90 pub fn discover(path: &Path) -> io::Result<Vec<ProjectManifest>> {
91 if let Some(project_json) = find_in_parent_dirs(path, "rust-project.json") { 91 if let Some(project_json) = find_in_parent_dirs(path, "rust-project.json") {
92 return Ok(vec![ProjectRoot::ProjectJson(project_json)]); 92 return Ok(vec![ProjectManifest::ProjectJson(project_json)]);
93 } 93 }
94 return find_cargo_toml(path) 94 return find_cargo_toml(path)
95 .map(|paths| paths.into_iter().map(ProjectRoot::CargoToml).collect()); 95 .map(|paths| paths.into_iter().map(ProjectManifest::CargoToml).collect());
96 96
97 fn find_cargo_toml(path: &Path) -> io::Result<Vec<PathBuf>> { 97 fn find_cargo_toml(path: &Path) -> io::Result<Vec<PathBuf>> {
98 match find_in_parent_dirs(path, "Cargo.toml") { 98 match find_in_parent_dirs(path, "Cargo.toml") {
@@ -129,10 +129,10 @@ impl ProjectRoot {
129 } 129 }
130 } 130 }
131 131
132 pub fn discover_all(paths: &[impl AsRef<Path>]) -> Vec<ProjectRoot> { 132 pub fn discover_all(paths: &[impl AsRef<Path>]) -> Vec<ProjectManifest> {
133 let mut res = paths 133 let mut res = paths
134 .iter() 134 .iter()
135 .filter_map(|it| ProjectRoot::discover(it.as_ref()).ok()) 135 .filter_map(|it| ProjectManifest::discover(it.as_ref()).ok())
136 .flatten() 136 .flatten()
137 .collect::<FxHashSet<_>>() 137 .collect::<FxHashSet<_>>()
138 .into_iter() 138 .into_iter()
@@ -144,12 +144,12 @@ impl ProjectRoot {
144 144
145impl ProjectWorkspace { 145impl ProjectWorkspace {
146 pub fn load( 146 pub fn load(
147 root: ProjectRoot, 147 root: ProjectManifest,
148 cargo_features: &CargoConfig, 148 cargo_features: &CargoConfig,
149 with_sysroot: bool, 149 with_sysroot: bool,
150 ) -> Result<ProjectWorkspace> { 150 ) -> Result<ProjectWorkspace> {
151 let res = match root { 151 let res = match root {
152 ProjectRoot::ProjectJson(project_json) => { 152 ProjectManifest::ProjectJson(project_json) => {
153 let file = File::open(&project_json).with_context(|| { 153 let file = File::open(&project_json).with_context(|| {
154 format!("Failed to open json file {}", project_json.display()) 154 format!("Failed to open json file {}", project_json.display())
155 })?; 155 })?;
@@ -160,7 +160,7 @@ impl ProjectWorkspace {
160 })?, 160 })?,
161 } 161 }
162 } 162 }
163 ProjectRoot::CargoToml(cargo_toml) => { 163 ProjectManifest::CargoToml(cargo_toml) => {
164 let cargo = CargoWorkspace::from_cargo_metadata(&cargo_toml, cargo_features) 164 let cargo = CargoWorkspace::from_cargo_metadata(&cargo_toml, cargo_features)
165 .with_context(|| { 165 .with_context(|| {
166 format!( 166 format!(
diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs
index 8eaf75ff6..67491b42a 100644
--- a/crates/rust-analyzer/src/cli/load_cargo.rs
+++ b/crates/rust-analyzer/src/cli/load_cargo.rs
@@ -8,7 +8,7 @@ use crossbeam_channel::{unbounded, Receiver};
8use ra_db::{ExternSourceId, FileId, SourceRootId}; 8use ra_db::{ExternSourceId, FileId, SourceRootId};
9use ra_ide::{AnalysisChange, AnalysisHost}; 9use ra_ide::{AnalysisChange, AnalysisHost};
10use ra_project_model::{ 10use ra_project_model::{
11 get_rustc_cfg_options, CargoConfig, PackageRoot, ProcMacroClient, ProjectRoot, ProjectWorkspace, 11 get_rustc_cfg_options, CargoConfig, PackageRoot, ProcMacroClient, ProjectManifest, ProjectWorkspace,
12}; 12};
13use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask, Watch}; 13use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask, Watch};
14use rustc_hash::{FxHashMap, FxHashSet}; 14use rustc_hash::{FxHashMap, FxHashSet};
@@ -28,7 +28,7 @@ pub fn load_cargo(
28 with_proc_macro: bool, 28 with_proc_macro: bool,
29) -> Result<(AnalysisHost, FxHashMap<SourceRootId, PackageRoot>)> { 29) -> Result<(AnalysisHost, FxHashMap<SourceRootId, PackageRoot>)> {
30 let root = std::env::current_dir()?.join(root); 30 let root = std::env::current_dir()?.join(root);
31 let root = ProjectRoot::discover_single(&root)?; 31 let root = ProjectManifest::discover_single(&root)?;
32 let ws = ProjectWorkspace::load( 32 let ws = ProjectWorkspace::load(
33 root, 33 root,
34 &CargoConfig { load_out_dirs_from_check, ..Default::default() }, 34 &CargoConfig { load_out_dirs_from_check, ..Default::default() },
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 82348c6fc..ea5b4c91c 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -28,7 +28,7 @@ use lsp_types::{
28use ra_flycheck::{CheckTask, Status}; 28use ra_flycheck::{CheckTask, Status};
29use ra_ide::{Canceled, FileId, LibraryData, LineIndex, SourceRootId}; 29use ra_ide::{Canceled, FileId, LibraryData, LineIndex, SourceRootId};
30use ra_prof::profile; 30use ra_prof::profile;
31use ra_project_model::{PackageRoot, ProjectRoot, ProjectWorkspace}; 31use ra_project_model::{PackageRoot, ProjectManifest, ProjectWorkspace};
32use ra_vfs::{VfsFile, VfsTask, Watch}; 32use ra_vfs::{VfsFile, VfsTask, Watch};
33use relative_path::RelativePathBuf; 33use relative_path::RelativePathBuf;
34use rustc_hash::FxHashSet; 34use rustc_hash::FxHashSet;
@@ -96,7 +96,7 @@ pub fn main_loop(ws_roots: Vec<PathBuf>, config: Config, connection: Connection)
96 let mut global_state = { 96 let mut global_state = {
97 let workspaces = { 97 let workspaces = {
98 // FIXME: support dynamic workspace loading. 98 // FIXME: support dynamic workspace loading.
99 let project_roots = ProjectRoot::discover_all(&ws_roots); 99 let project_roots = ProjectManifest::discover_all(&ws_roots);
100 100
101 if project_roots.is_empty() && config.notifications.cargo_toml_not_found { 101 if project_roots.is_empty() && config.notifications.cargo_toml_not_found {
102 show_message( 102 show_message(