aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_project_model/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_project_model/src')
-rw-r--r--crates/ra_project_model/src/cargo_workspace.rs6
-rw-r--r--crates/ra_project_model/src/lib.rs2
2 files changed, 6 insertions, 2 deletions
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs
index 1b3c246c7..1832c101f 100644
--- a/crates/ra_project_model/src/cargo_workspace.rs
+++ b/crates/ra_project_model/src/cargo_workspace.rs
@@ -21,7 +21,7 @@ use crate::Result;
21pub struct CargoWorkspace { 21pub struct CargoWorkspace {
22 packages: Arena<Package, PackageData>, 22 packages: Arena<Package, PackageData>,
23 targets: Arena<Target, TargetData>, 23 targets: Arena<Target, TargetData>,
24 pub(crate) workspace_root: PathBuf, 24 workspace_root: PathBuf,
25} 25}
26 26
27#[derive(Deserialize, Clone, Debug, PartialEq, Eq)] 27#[derive(Deserialize, Clone, Debug, PartialEq, Eq)]
@@ -225,4 +225,8 @@ impl CargoWorkspace {
225 pub fn target_by_root(&self, root: &Path) -> Option<Target> { 225 pub fn target_by_root(&self, root: &Path) -> Option<Target> {
226 self.packages().filter_map(|pkg| pkg.targets(self).find(|it| it.root(self) == root)).next() 226 self.packages().filter_map(|pkg| pkg.targets(self).find(|it| it.root(self) == root)).next()
227 } 227 }
228
229 pub fn workspace_root(&self) -> &Path {
230 &self.workspace_root
231 }
228} 232}
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index b7f6a9b57..6a104e6f2 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -333,7 +333,7 @@ impl ProjectWorkspace {
333 pub fn workspace_root_for(&self, path: &Path) -> Option<&Path> { 333 pub fn workspace_root_for(&self, path: &Path) -> Option<&Path> {
334 match self { 334 match self {
335 ProjectWorkspace::Cargo { cargo, .. } => { 335 ProjectWorkspace::Cargo { cargo, .. } => {
336 Some(cargo.workspace_root.as_ref()).filter(|root| path.starts_with(root)) 336 Some(cargo.workspace_root()).filter(|root| path.starts_with(root))
337 } 337 }
338 ProjectWorkspace::Json { project: JsonProject { roots, .. } } => roots 338 ProjectWorkspace::Json { project: JsonProject { roots, .. } } => roots
339 .iter() 339 .iter()