From 677c0eeccbc1d8bb5e05d47476b3b77592b7e4bb Mon Sep 17 00:00:00 2001 From: David Barsky Date: Mon, 13 Mar 2023 14:45:41 -0400 Subject: [PATCH] Add path of workspace root folders to status output --- crates/project-model/src/workspace.rs | 8 ++++++++ crates/rust-analyzer/src/handlers.rs | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/crates/project-model/src/workspace.rs b/crates/project-model/src/workspace.rs index faa6816fdc20..862d1a8b4aaf 100644 --- a/crates/project-model/src/workspace.rs +++ b/crates/project-model/src/workspace.rs @@ -450,6 +450,14 @@ impl ProjectWorkspace { } } + pub fn workspace_definition_path(&self) -> Option<&AbsPath> { + match self { + ProjectWorkspace::Cargo { cargo, .. } => Some(cargo.workspace_root()), + ProjectWorkspace::Json { project, .. } => Some(project.path()), + ProjectWorkspace::DetachedFiles { .. } => None, + } + } + pub fn find_sysroot_proc_macro_srv(&self) -> Option { match self { ProjectWorkspace::Cargo { sysroot: Some(sysroot), .. } diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 32ac9a42dec3..e95d68b70a35 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -29,7 +29,7 @@ use project_model::{ManifestPath, ProjectWorkspace, TargetKind}; use serde_json::json; use stdx::{format_to, never}; use syntax::{algo, ast, AstNode, TextRange, TextSize}; -use vfs::AbsPathBuf; +use vfs::{AbsPath, AbsPathBuf}; use crate::{ cargo_target_spec::CargoTargetSpec, @@ -84,6 +84,15 @@ pub(crate) fn handle_analyzer_status( snap.workspaces.len(), if snap.workspaces.len() == 1 { "" } else { "s" } ); + + format_to!( + buf, + "Workspace root folders: {:?}", + snap.workspaces + .iter() + .flat_map(|ws| ws.workspace_definition_path()) + .collect::>() + ); } buf.push_str("\nAnalysis:\n"); buf.push_str(