Skip to content

Commit b039f0d

Browse files
committed
Simplify
1 parent 751b879 commit b039f0d

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

crates/rust-analyzer/src/global_state.rs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use parking_lot::RwLock;
1212
use ra_db::{CrateId, VfsPath};
1313
use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FileId};
1414
use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target};
15-
use stdx::format_to;
1615

1716
use crate::{
1817
config::Config,
@@ -82,7 +81,7 @@ pub(crate) struct GlobalStateSnapshot {
8281
pub(crate) check_fixes: CheckFixes,
8382
pub(crate) latest_requests: Arc<RwLock<LatestRequests>>,
8483
vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>,
85-
workspaces: Arc<Vec<ProjectWorkspace>>,
84+
pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>,
8685
}
8786

8887
impl GlobalState {
@@ -233,26 +232,6 @@ impl GlobalStateSnapshot {
233232
ProjectWorkspace::Json { .. } => None,
234233
})
235234
}
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-
}
256235
}
257236

258237
pub(crate) fn file_id_to_url(vfs: &vfs::Vfs, id: FileId) -> Url {

crates/rust-analyzer/src/handlers.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,20 @@ use crate::{
3939

4040
pub(crate) fn handle_analyzer_status(snap: GlobalStateSnapshot, _: ()) -> Result<String> {
4141
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+
);
4356
format_to!(buf, "\n\nrequests:\n");
4457
let requests = snap.latest_requests.read();
4558
for (is_last, r) in requests.iter() {

0 commit comments

Comments
 (0)