mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Simplify
This commit is contained in:
parent
751b8792a2
commit
b039f0d1ba
2 changed files with 15 additions and 23 deletions
|
@ -12,7 +12,6 @@ use parking_lot::RwLock;
|
||||||
use ra_db::{CrateId, VfsPath};
|
use ra_db::{CrateId, VfsPath};
|
||||||
use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FileId};
|
use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FileId};
|
||||||
use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target};
|
use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target};
|
||||||
use stdx::format_to;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::Config,
|
config::Config,
|
||||||
|
@ -82,7 +81,7 @@ pub(crate) struct GlobalStateSnapshot {
|
||||||
pub(crate) check_fixes: CheckFixes,
|
pub(crate) check_fixes: CheckFixes,
|
||||||
pub(crate) latest_requests: Arc<RwLock<LatestRequests>>,
|
pub(crate) latest_requests: Arc<RwLock<LatestRequests>>,
|
||||||
vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>,
|
vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>,
|
||||||
workspaces: Arc<Vec<ProjectWorkspace>>,
|
pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlobalState {
|
impl GlobalState {
|
||||||
|
@ -233,26 +232,6 @@ impl GlobalStateSnapshot {
|
||||||
ProjectWorkspace::Json { .. } => None,
|
ProjectWorkspace::Json { .. } => None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn status(&self) -> String {
|
|
||||||
let mut buf = String::new();
|
|
||||||
if self.workspaces.is_empty() {
|
|
||||||
buf.push_str("no workspaces\n")
|
|
||||||
} else {
|
|
||||||
buf.push_str("workspaces:\n");
|
|
||||||
for w in self.workspaces.iter() {
|
|
||||||
format_to!(buf, "{} packages loaded\n", w.n_packages());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
buf.push_str("\nanalysis:\n");
|
|
||||||
buf.push_str(
|
|
||||||
&self
|
|
||||||
.analysis
|
|
||||||
.status()
|
|
||||||
.unwrap_or_else(|_| "Analysis retrieval was cancelled".to_owned()),
|
|
||||||
);
|
|
||||||
buf
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn file_id_to_url(vfs: &vfs::Vfs, id: FileId) -> Url {
|
pub(crate) fn file_id_to_url(vfs: &vfs::Vfs, id: FileId) -> Url {
|
||||||
|
|
|
@ -39,7 +39,20 @@ use crate::{
|
||||||
|
|
||||||
pub(crate) fn handle_analyzer_status(snap: GlobalStateSnapshot, _: ()) -> Result<String> {
|
pub(crate) fn handle_analyzer_status(snap: GlobalStateSnapshot, _: ()) -> Result<String> {
|
||||||
let _p = profile("handle_analyzer_status");
|
let _p = profile("handle_analyzer_status");
|
||||||
let mut buf = snap.status();
|
|
||||||
|
let mut buf = String::new();
|
||||||
|
if snap.workspaces.is_empty() {
|
||||||
|
buf.push_str("no workspaces\n")
|
||||||
|
} else {
|
||||||
|
buf.push_str("workspaces:\n");
|
||||||
|
for w in snap.workspaces.iter() {
|
||||||
|
format_to!(buf, "{} packages loaded\n", w.n_packages());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buf.push_str("\nanalysis:\n");
|
||||||
|
buf.push_str(
|
||||||
|
&snap.analysis.status().unwrap_or_else(|_| "Analysis retrieval was cancelled".to_owned()),
|
||||||
|
);
|
||||||
format_to!(buf, "\n\nrequests:\n");
|
format_to!(buf, "\n\nrequests:\n");
|
||||||
let requests = snap.latest_requests.read();
|
let requests = snap.latest_requests.read();
|
||||||
for (is_last, r) in requests.iter() {
|
for (is_last, r) in requests.iter() {
|
||||||
|
|
Loading…
Reference in a new issue