aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/global_state.rs23
-rw-r--r--crates/rust-analyzer/src/handlers.rs15
2 files changed, 15 insertions, 23 deletions
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs
index 6a5ba138f..7533bb319 100644
--- a/crates/rust-analyzer/src/global_state.rs
+++ b/crates/rust-analyzer/src/global_state.rs
@@ -12,7 +12,6 @@ use parking_lot::RwLock;
12use ra_db::{CrateId, VfsPath}; 12use ra_db::{CrateId, VfsPath};
13use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FileId}; 13use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FileId};
14use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target}; 14use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target};
15use stdx::format_to;
16 15
17use crate::{ 16use crate::{
18 config::Config, 17 config::Config,
@@ -82,7 +81,7 @@ pub(crate) struct GlobalStateSnapshot {
82 pub(crate) check_fixes: CheckFixes, 81 pub(crate) check_fixes: CheckFixes,
83 pub(crate) latest_requests: Arc<RwLock<LatestRequests>>, 82 pub(crate) latest_requests: Arc<RwLock<LatestRequests>>,
84 vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>, 83 vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>,
85 workspaces: Arc<Vec<ProjectWorkspace>>, 84 pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>,
86} 85}
87 86
88impl GlobalState { 87impl GlobalState {
@@ -233,26 +232,6 @@ impl GlobalStateSnapshot {
233 ProjectWorkspace::Json { .. } => None, 232 ProjectWorkspace::Json { .. } => None,
234 }) 233 })
235 } 234 }
236
237 pub(crate) fn status(&self) -> String {
238 let mut buf = String::new();
239 if self.workspaces.is_empty() {
240 buf.push_str("no workspaces\n")
241 } else {
242 buf.push_str("workspaces:\n");
243 for w in self.workspaces.iter() {
244 format_to!(buf, "{} packages loaded\n", w.n_packages());
245 }
246 }
247 buf.push_str("\nanalysis:\n");
248 buf.push_str(
249 &self
250 .analysis
251 .status()
252 .unwrap_or_else(|_| "Analysis retrieval was cancelled".to_owned()),
253 );
254 buf
255 }
256} 235}
257 236
258pub(crate) fn file_id_to_url(vfs: &vfs::Vfs, id: FileId) -> Url { 237pub(crate) fn file_id_to_url(vfs: &vfs::Vfs, id: FileId) -> Url {
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 12b494496..6c21f25fe 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -39,7 +39,20 @@ use crate::{
39 39
40pub(crate) fn handle_analyzer_status(snap: GlobalStateSnapshot, _: ()) -> Result<String> { 40pub(crate) fn handle_analyzer_status(snap: GlobalStateSnapshot, _: ()) -> Result<String> {
41 let _p = profile("handle_analyzer_status"); 41 let _p = profile("handle_analyzer_status");
42 let mut buf = snap.status(); 42
43 let mut buf = String::new();
44 if snap.workspaces.is_empty() {
45 buf.push_str("no workspaces\n")
46 } else {
47 buf.push_str("workspaces:\n");
48 for w in snap.workspaces.iter() {
49 format_to!(buf, "{} packages loaded\n", w.n_packages());
50 }
51 }
52 buf.push_str("\nanalysis:\n");
53 buf.push_str(
54 &snap.analysis.status().unwrap_or_else(|_| "Analysis retrieval was cancelled".to_owned()),
55 );
43 format_to!(buf, "\n\nrequests:\n"); 56 format_to!(buf, "\n\nrequests:\n");
44 let requests = snap.latest_requests.read(); 57 let requests = snap.latest_requests.read();
45 for (is_last, r) in requests.iter() { 58 for (is_last, r) in requests.iter() {