Skip to content

Commit 677c0ee

Browse files
committed
Add path of workspace root folders to status output
1 parent 9549753 commit 677c0ee

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

crates/project-model/src/workspace.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,14 @@ impl ProjectWorkspace {
450450
}
451451
}
452452

453+
pub fn workspace_definition_path(&self) -> Option<&AbsPath> {
454+
match self {
455+
ProjectWorkspace::Cargo { cargo, .. } => Some(cargo.workspace_root()),
456+
ProjectWorkspace::Json { project, .. } => Some(project.path()),
457+
ProjectWorkspace::DetachedFiles { .. } => None,
458+
}
459+
}
460+
453461
pub fn find_sysroot_proc_macro_srv(&self) -> Option<AbsPathBuf> {
454462
match self {
455463
ProjectWorkspace::Cargo { sysroot: Some(sysroot), .. }

crates/rust-analyzer/src/handlers.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use project_model::{ManifestPath, ProjectWorkspace, TargetKind};
2929
use serde_json::json;
3030
use stdx::{format_to, never};
3131
use syntax::{algo, ast, AstNode, TextRange, TextSize};
32-
use vfs::AbsPathBuf;
32+
use vfs::{AbsPath, AbsPathBuf};
3333

3434
use crate::{
3535
cargo_target_spec::CargoTargetSpec,
@@ -84,6 +84,15 @@ pub(crate) fn handle_analyzer_status(
8484
snap.workspaces.len(),
8585
if snap.workspaces.len() == 1 { "" } else { "s" }
8686
);
87+
88+
format_to!(
89+
buf,
90+
"Workspace root folders: {:?}",
91+
snap.workspaces
92+
.iter()
93+
.flat_map(|ws| ws.workspace_definition_path())
94+
.collect::<Vec<&AbsPath>>()
95+
);
8796
}
8897
buf.push_str("\nAnalysis:\n");
8998
buf.push_str(

0 commit comments

Comments
 (0)