Skip to content

Commit 03a7619

Browse files
committed
Rename ProjectRoot -> ProjectManifest
1 parent 0a88de8 commit 03a7619

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

crates/ra_project_model/src/lib.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,24 @@ impl PackageRoot {
5858
}
5959

6060
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)]
61-
pub enum ProjectRoot {
61+
pub enum ProjectManifest {
6262
ProjectJson(PathBuf),
6363
CargoToml(PathBuf),
6464
}
6565

66-
impl ProjectRoot {
67-
pub fn from_manifest_file(path: PathBuf) -> Result<ProjectRoot> {
66+
impl ProjectManifest {
67+
pub fn from_manifest_file(path: PathBuf) -> Result<ProjectManifest> {
6868
if path.ends_with("rust-project.json") {
69-
return Ok(ProjectRoot::ProjectJson(path));
69+
return Ok(ProjectManifest::ProjectJson(path));
7070
}
7171
if path.ends_with("Cargo.toml") {
72-
return Ok(ProjectRoot::CargoToml(path));
72+
return Ok(ProjectManifest::CargoToml(path));
7373
}
7474
bail!("project root must point to Cargo.toml or rust-project.json: {}", path.display())
7575
}
7676

77-
pub fn discover_single(path: &Path) -> Result<ProjectRoot> {
78-
let mut candidates = ProjectRoot::discover(path)?;
77+
pub fn discover_single(path: &Path) -> Result<ProjectManifest> {
78+
let mut candidates = ProjectManifest::discover(path)?;
7979
let res = match candidates.pop() {
8080
None => bail!("no projects"),
8181
Some(it) => it,
@@ -87,12 +87,12 @@ impl ProjectRoot {
8787
Ok(res)
8888
}
8989

90-
pub fn discover(path: &Path) -> io::Result<Vec<ProjectRoot>> {
90+
pub fn discover(path: &Path) -> io::Result<Vec<ProjectManifest>> {
9191
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)]);
9393
}
9494
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());
9696

9797
fn find_cargo_toml(path: &Path) -> io::Result<Vec<PathBuf>> {
9898
match find_in_parent_dirs(path, "Cargo.toml") {
@@ -129,10 +129,10 @@ impl ProjectRoot {
129129
}
130130
}
131131

132-
pub fn discover_all(paths: &[impl AsRef<Path>]) -> Vec<ProjectRoot> {
132+
pub fn discover_all(paths: &[impl AsRef<Path>]) -> Vec<ProjectManifest> {
133133
let mut res = paths
134134
.iter()
135-
.filter_map(|it| ProjectRoot::discover(it.as_ref()).ok())
135+
.filter_map(|it| ProjectManifest::discover(it.as_ref()).ok())
136136
.flatten()
137137
.collect::<FxHashSet<_>>()
138138
.into_iter()
@@ -144,12 +144,12 @@ impl ProjectRoot {
144144

145145
impl ProjectWorkspace {
146146
pub fn load(
147-
root: ProjectRoot,
147+
root: ProjectManifest,
148148
cargo_features: &CargoConfig,
149149
with_sysroot: bool,
150150
) -> Result<ProjectWorkspace> {
151151
let res = match root {
152-
ProjectRoot::ProjectJson(project_json) => {
152+
ProjectManifest::ProjectJson(project_json) => {
153153
let file = File::open(&project_json).with_context(|| {
154154
format!("Failed to open json file {}", project_json.display())
155155
})?;
@@ -160,7 +160,7 @@ impl ProjectWorkspace {
160160
})?,
161161
}
162162
}
163-
ProjectRoot::CargoToml(cargo_toml) => {
163+
ProjectManifest::CargoToml(cargo_toml) => {
164164
let cargo = CargoWorkspace::from_cargo_metadata(&cargo_toml, cargo_features)
165165
.with_context(|| {
166166
format!(

crates/rust-analyzer/src/cli/load_cargo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crossbeam_channel::{unbounded, Receiver};
88
use ra_db::{ExternSourceId, FileId, SourceRootId};
99
use ra_ide::{AnalysisChange, AnalysisHost};
1010
use ra_project_model::{
11-
get_rustc_cfg_options, CargoConfig, PackageRoot, ProcMacroClient, ProjectRoot, ProjectWorkspace,
11+
get_rustc_cfg_options, CargoConfig, PackageRoot, ProcMacroClient, ProjectManifest, ProjectWorkspace,
1212
};
1313
use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask, Watch};
1414
use rustc_hash::{FxHashMap, FxHashSet};
@@ -28,7 +28,7 @@ pub fn load_cargo(
2828
with_proc_macro: bool,
2929
) -> Result<(AnalysisHost, FxHashMap<SourceRootId, PackageRoot>)> {
3030
let root = std::env::current_dir()?.join(root);
31-
let root = ProjectRoot::discover_single(&root)?;
31+
let root = ProjectManifest::discover_single(&root)?;
3232
let ws = ProjectWorkspace::load(
3333
root,
3434
&CargoConfig { load_out_dirs_from_check, ..Default::default() },

crates/rust-analyzer/src/main_loop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use lsp_types::{
2828
use ra_flycheck::{CheckTask, Status};
2929
use ra_ide::{Canceled, FileId, LibraryData, LineIndex, SourceRootId};
3030
use ra_prof::profile;
31-
use ra_project_model::{PackageRoot, ProjectRoot, ProjectWorkspace};
31+
use ra_project_model::{PackageRoot, ProjectManifest, ProjectWorkspace};
3232
use ra_vfs::{VfsFile, VfsTask, Watch};
3333
use relative_path::RelativePathBuf;
3434
use rustc_hash::FxHashSet;
@@ -96,7 +96,7 @@ pub fn main_loop(ws_roots: Vec<PathBuf>, config: Config, connection: Connection)
9696
let mut global_state = {
9797
let workspaces = {
9898
// FIXME: support dynamic workspace loading.
99-
let project_roots = ProjectRoot::discover_all(&ws_roots);
99+
let project_roots = ProjectManifest::discover_all(&ws_roots);
100100

101101
if project_roots.is_empty() && config.notifications.cargo_toml_not_found {
102102
show_message(

0 commit comments

Comments
 (0)