From 7d502c7f081a9eee4c2cfb30177100713c8fea92 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Fri, 18 Jun 2021 19:22:03 +0100 Subject: [PATCH 01/14] Recreate PR. --- .gitignore | 1 + crates/ide/src/status.rs | 17 +++++++++++++---- crates/rust-analyzer/src/handlers.rs | 16 +++++++++++----- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 7e097c0158..8199e35c08 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ generated_assists.adoc generated_features.adoc generated_diagnostic.adoc .DS_Store +.glitterrc diff --git a/crates/ide/src/status.rs b/crates/ide/src/status.rs index 49fde1945c..4d9ce38a41 100644 --- a/crates/ide/src/status.rs +++ b/crates/ide/src/status.rs @@ -34,15 +34,24 @@ fn macro_syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats { // image::https://user-images.githubusercontent.com/48062697/113065584-05f34500-91b1-11eb-98cc-5c196f76be7f.gif[] pub(crate) fn status(db: &RootDatabase, file_id: Option) -> String { let mut buf = String::new(); + let count = profile::countme::get_all(); format_to!(buf, "{}\n", FileTextQuery.in_db(db).entries::()); format_to!(buf, "{}\n", LibrarySymbolsQuery.in_db(db).entries::()); format_to!(buf, "{}\n", syntax_tree_stats(db)); - format_to!(buf, "{} (macros)\n", macro_syntax_tree_stats(db)); - format_to!(buf, "{} total\n", memory_usage()); - format_to!(buf, "\ncounts:\n{}", profile::countme::get_all()); + format_to!(buf, "{} (Macros)\n", macro_syntax_tree_stats(db)); + format_to!(buf, "{} Total\n", memory_usage()); + format_to!( + buf, + "\nCounts:\n{}", + if count.to_string().contains("all counts are zero") { + String::from("All counts are zero\n") + } else { + count.to_string() + } + ); if let Some(file_id) = file_id { - format_to!(buf, "\nfile info:\n"); + format_to!(buf, "\nFile info:\n"); let krate = crate::parent_module::crate_for(db, file_id).pop(); match krate { Some(krate) => { diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index ccf66294f1..ed43195dec 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -60,21 +60,27 @@ pub(crate) fn handle_analyzer_status( } if snap.workspaces.is_empty() { - buf.push_str("no workspaces\n") + buf.push_str("No workspaces\n") } else { - buf.push_str("workspaces:\n"); + buf.push_str("Workspaces:\n"); for w in snap.workspaces.iter() { - format_to!(buf, "{} packages loaded\n", w.n_packages()); + format_to!( + buf, + "Loaded {} packages across {} workspace{}.\n", + w.n_packages(), + snap.workspaces.len(), + if snap.workspaces.len() == 1 { "" } else { "s" } + ); } } - buf.push_str("\nanalysis:\n"); + buf.push_str("\nAnalysis:\n"); buf.push_str( &snap .analysis .status(file_id) .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(); for (is_last, r) in requests.iter() { let mark = if is_last { "*" } else { " " }; From 7aaadf929d225799a6ced4429cafeed759aaf1ba Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Fri, 18 Jun 2021 23:20:30 +0100 Subject: [PATCH 02/14] make workspaces look better --- crates/rust-analyzer/src/handlers.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index ed43195dec..3fd8b3cff7 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -63,15 +63,13 @@ pub(crate) fn handle_analyzer_status( buf.push_str("No workspaces\n") } else { buf.push_str("Workspaces:\n"); - for w in snap.workspaces.iter() { - format_to!( - buf, - "Loaded {} packages across {} workspace{}.\n", - w.n_packages(), - snap.workspaces.len(), - if snap.workspaces.len() == 1 { "" } else { "s" } - ); - } + format_to!( + buf, + "Loaded {:?} packages across {} workspace{}.\n", + snap.workspaces.iter().map(|w| w.n_packages()).sum::(), + snap.workspaces.len(), + if snap.workspaces.len() == 1 { "" } else { "s" } + ); } buf.push_str("\nAnalysis:\n"); buf.push_str( From 08ec80c0933394012847624e0d30f81411d6f580 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Fri, 18 Jun 2021 23:34:00 +0100 Subject: [PATCH 03/14] remove incorrect double blank new lines --- crates/ide/src/status.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ide/src/status.rs b/crates/ide/src/status.rs index 4d9ce38a41..a3020887e1 100644 --- a/crates/ide/src/status.rs +++ b/crates/ide/src/status.rs @@ -72,7 +72,7 @@ pub(crate) fn status(db: &RootDatabase, file_id: Option) -> String { } } - buf + buf.trim().to_string() } #[derive(Default)] From d2f7e0fea44b7fda460f38acc7d361259aaa1116 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Sat, 19 Jun 2021 07:51:44 +0100 Subject: [PATCH 04/14] clean up some wording --- crates/ide/src/status.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/ide/src/status.rs b/crates/ide/src/status.rs index a3020887e1..ff18e2d2d1 100644 --- a/crates/ide/src/status.rs +++ b/crates/ide/src/status.rs @@ -39,7 +39,7 @@ pub(crate) fn status(db: &RootDatabase, file_id: Option) -> String { format_to!(buf, "{}\n", LibrarySymbolsQuery.in_db(db).entries::()); format_to!(buf, "{}\n", syntax_tree_stats(db)); format_to!(buf, "{} (Macros)\n", macro_syntax_tree_stats(db)); - format_to!(buf, "{} Total\n", memory_usage()); + format_to!(buf, "{} in total\n", memory_usage()); format_to!( buf, "\nCounts:\n{}", @@ -68,7 +68,7 @@ pub(crate) fn status(db: &RootDatabase, file_id: Option) -> String { .format(", "); format_to!(buf, "deps: {}\n", deps); } - None => format_to!(buf, "does not belong to any crate"), + None => format_to!(buf, "Does not belong to any crate"), } } @@ -83,7 +83,7 @@ struct FilesStats { impl fmt::Display for FilesStats { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "{} ({}) files", self.total, self.size) + write!(fmt, "{} of files", self.size) } } @@ -109,7 +109,7 @@ pub(crate) struct SyntaxTreeStats { impl fmt::Display for SyntaxTreeStats { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "{} trees, {} retained", self.total, self.retained) + write!(fmt, "{} trees, {} preserved", self.total, self.retained) } } @@ -151,7 +151,7 @@ struct LibrarySymbolsStats { impl fmt::Display for LibrarySymbolsStats { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "{} ({}) index symbols", self.total, self.size) + write!(fmt, "{} of index symbols", self.size) } } From 664cc8c754646188af39d25dd67e6057109f7c22 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Sat, 19 Jun 2021 08:12:46 +0100 Subject: [PATCH 05/14] use num_format --- Cargo.lock | 33 +++++++++++++++++++++++++--- crates/ide/Cargo.toml | 2 +- crates/ide/src/status.rs | 4 +++- crates/rust-analyzer/Cargo.toml | 2 +- crates/rust-analyzer/src/handlers.rs | 5 +++-- 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5066d5f0f5..51e11d28df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -47,6 +47,15 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33954243bd79057c2de7338850b85983a44588021f8a5fee574a8888c6de4344" +[[package]] +name = "arrayvec" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" +dependencies = [ + "nodrop", +] + [[package]] name = "arrayvec" version = "0.7.0" @@ -459,7 +468,7 @@ dependencies = [ name = "hir" version = "0.0.0" dependencies = [ - "arrayvec", + "arrayvec 0.7.0", "base_db", "cfg", "either", @@ -529,7 +538,7 @@ dependencies = [ name = "hir_ty" version = "0.0.0" dependencies = [ - "arrayvec", + "arrayvec 0.7.0", "base_db", "chalk-ir", "chalk-recursive", @@ -582,6 +591,7 @@ dependencies = [ "indexmap", "itertools", "log", + "num-format", "oorandom", "profile", "pulldown-cmark", @@ -934,6 +944,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + [[package]] name = "notify" version = "5.0.0-pre.9" @@ -960,6 +976,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-format" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bafe4179722c2894288ee77a9f044f02811c86af699344c498b0840c698a2465" +dependencies = [ + "arrayvec 0.4.12", + "itoa", +] + [[package]] name = "num_cpus" version = "1.13.0" @@ -1317,6 +1343,7 @@ dependencies = [ "lsp-types", "mbe", "mimalloc", + "num-format", "oorandom", "parking_lot", "proc_macro_srv", @@ -1560,7 +1587,7 @@ dependencies = [ name = "syntax" version = "0.0.0" dependencies = [ - "arrayvec", + "arrayvec 0.7.0", "cov-mark", "expect-test", "indexmap", diff --git a/crates/ide/Cargo.toml b/crates/ide/Cargo.toml index 0e84473940..e76fa5c2dd 100644 --- a/crates/ide/Cargo.toml +++ b/crates/ide/Cargo.toml @@ -21,7 +21,7 @@ pulldown-cmark-to-cmark = "6.0.0" pulldown-cmark = { version = "0.8.0", default-features = false } url = "2.1.1" dot = "0.1.4" - +num-format = "0.4.0" stdx = { path = "../stdx", version = "0.0.0" } syntax = { path = "../syntax", version = "0.0.0" } text_edit = { path = "../text_edit", version = "0.0.0" } diff --git a/crates/ide/src/status.rs b/crates/ide/src/status.rs index ff18e2d2d1..f0b670cd6e 100644 --- a/crates/ide/src/status.rs +++ b/crates/ide/src/status.rs @@ -10,6 +10,7 @@ use ide_db::{ RootDatabase, }; use itertools::Itertools; +use num_format::{Buffer, Locale}; use profile::{memory_usage, Bytes}; use rustc_hash::FxHashMap; use stdx::format_to; @@ -109,7 +110,8 @@ pub(crate) struct SyntaxTreeStats { impl fmt::Display for SyntaxTreeStats { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "{} trees, {} preserved", self.total, self.retained) + let buf = Buffer::default().write_formatted(&self.total, &Locale::en); + write!(fmt, "{} trees, {} preserved", buf.to_string(), self.retained) } } diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 3010815df7..9be140b58b 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -38,7 +38,7 @@ tracing = "0.1" tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry"] } tracing-tree = { version = "0.1.4" } always-assert = "0.1" - +num-format = "0.4.0" stdx = { path = "../stdx", version = "0.0.0" } flycheck = { path = "../flycheck", version = "0.0.0" } ide = { path = "../ide", version = "0.0.0" } diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 3fd8b3cff7..9858ac717f 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -25,6 +25,7 @@ use lsp_types::{ SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, SymbolTag, TextDocumentIdentifier, TextDocumentPositionParams, Url, WorkspaceEdit, }; +use num_format::{Locale, ToFormattedString}; use project_model::TargetKind; use serde::{Deserialize, Serialize}; use serde_json::{json, to_value}; @@ -66,8 +67,8 @@ pub(crate) fn handle_analyzer_status( format_to!( buf, "Loaded {:?} packages across {} workspace{}.\n", - snap.workspaces.iter().map(|w| w.n_packages()).sum::(), - snap.workspaces.len(), + snap.workspaces.iter().map(|w| w.n_packages()).sum::().to_formatted_string(&Locale::en), + snap.workspaces.len().to_formatted_string(&Locale::en), if snap.workspaces.len() == 1 { "" } else { "s" } ); } From d8209e6378aa87900ccb093aec7f45aa0a99ab50 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Sat, 19 Jun 2021 08:12:58 +0100 Subject: [PATCH 06/14] fmt --- crates/rust-analyzer/src/handlers.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 9858ac717f..2bda4716a6 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -67,7 +67,11 @@ pub(crate) fn handle_analyzer_status( format_to!( buf, "Loaded {:?} packages across {} workspace{}.\n", - snap.workspaces.iter().map(|w| w.n_packages()).sum::().to_formatted_string(&Locale::en), + snap.workspaces + .iter() + .map(|w| w.n_packages()) + .sum::() + .to_formatted_string(&Locale::en), snap.workspaces.len().to_formatted_string(&Locale::en), if snap.workspaces.len() == 1 { "" } else { "s" } ); From 673933e2f73c32588c075d712036372d364dc9fb Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Sat, 19 Jun 2021 09:44:11 +0100 Subject: [PATCH 07/14] update crate and deps section --- crates/ide/src/status.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ide/src/status.rs b/crates/ide/src/status.rs index f0b670cd6e..a9ab6337d7 100644 --- a/crates/ide/src/status.rs +++ b/crates/ide/src/status.rs @@ -61,13 +61,13 @@ pub(crate) fn status(db: &RootDatabase, file_id: Option) -> String { Some(it) => format!("{}({:?})", it, krate), None => format!("{:?}", krate), }; - format_to!(buf, "crate: {}\n", display_crate(krate)); + format_to!(buf, "Crate: {}\n", display_crate(krate)); let deps = crate_graph[krate] .dependencies .iter() .map(|dep| format!("{}={:?}", dep.name, dep.crate_id)) .format(", "); - format_to!(buf, "deps: {}\n", deps); + format_to!(buf, "Dependencies: {}\n", deps); } None => format_to!(buf, "Does not belong to any crate"), } From 044e21ae08ad96283783a6e39bee0a775caa2d70 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Sat, 19 Jun 2021 10:14:15 +0100 Subject: [PATCH 08/14] remove num_format --- Cargo.lock | 33 +++------------------------- crates/ide/Cargo.toml | 1 - crates/ide/src/status.rs | 4 +--- crates/rust-analyzer/Cargo.toml | 1 - crates/rust-analyzer/src/handlers.rs | 9 ++------ 5 files changed, 6 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 51e11d28df..5066d5f0f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -47,15 +47,6 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33954243bd79057c2de7338850b85983a44588021f8a5fee574a8888c6de4344" -[[package]] -name = "arrayvec" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" -dependencies = [ - "nodrop", -] - [[package]] name = "arrayvec" version = "0.7.0" @@ -468,7 +459,7 @@ dependencies = [ name = "hir" version = "0.0.0" dependencies = [ - "arrayvec 0.7.0", + "arrayvec", "base_db", "cfg", "either", @@ -538,7 +529,7 @@ dependencies = [ name = "hir_ty" version = "0.0.0" dependencies = [ - "arrayvec 0.7.0", + "arrayvec", "base_db", "chalk-ir", "chalk-recursive", @@ -591,7 +582,6 @@ dependencies = [ "indexmap", "itertools", "log", - "num-format", "oorandom", "profile", "pulldown-cmark", @@ -944,12 +934,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "nodrop" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" - [[package]] name = "notify" version = "5.0.0-pre.9" @@ -976,16 +960,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "num-format" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bafe4179722c2894288ee77a9f044f02811c86af699344c498b0840c698a2465" -dependencies = [ - "arrayvec 0.4.12", - "itoa", -] - [[package]] name = "num_cpus" version = "1.13.0" @@ -1343,7 +1317,6 @@ dependencies = [ "lsp-types", "mbe", "mimalloc", - "num-format", "oorandom", "parking_lot", "proc_macro_srv", @@ -1587,7 +1560,7 @@ dependencies = [ name = "syntax" version = "0.0.0" dependencies = [ - "arrayvec 0.7.0", + "arrayvec", "cov-mark", "expect-test", "indexmap", diff --git a/crates/ide/Cargo.toml b/crates/ide/Cargo.toml index e76fa5c2dd..3bc07aedf5 100644 --- a/crates/ide/Cargo.toml +++ b/crates/ide/Cargo.toml @@ -21,7 +21,6 @@ pulldown-cmark-to-cmark = "6.0.0" pulldown-cmark = { version = "0.8.0", default-features = false } url = "2.1.1" dot = "0.1.4" -num-format = "0.4.0" stdx = { path = "../stdx", version = "0.0.0" } syntax = { path = "../syntax", version = "0.0.0" } text_edit = { path = "../text_edit", version = "0.0.0" } diff --git a/crates/ide/src/status.rs b/crates/ide/src/status.rs index a9ab6337d7..22f1a09091 100644 --- a/crates/ide/src/status.rs +++ b/crates/ide/src/status.rs @@ -10,7 +10,6 @@ use ide_db::{ RootDatabase, }; use itertools::Itertools; -use num_format::{Buffer, Locale}; use profile::{memory_usage, Bytes}; use rustc_hash::FxHashMap; use stdx::format_to; @@ -110,8 +109,7 @@ pub(crate) struct SyntaxTreeStats { impl fmt::Display for SyntaxTreeStats { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - let buf = Buffer::default().write_formatted(&self.total, &Locale::en); - write!(fmt, "{} trees, {} preserved", buf.to_string(), self.retained) + write!(fmt, "{} trees, {} preserved", self.total, self.retained) } } diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 9be140b58b..3f35ce1ebc 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -38,7 +38,6 @@ tracing = "0.1" tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry"] } tracing-tree = { version = "0.1.4" } always-assert = "0.1" -num-format = "0.4.0" stdx = { path = "../stdx", version = "0.0.0" } flycheck = { path = "../flycheck", version = "0.0.0" } ide = { path = "../ide", version = "0.0.0" } diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 2bda4716a6..3fd8b3cff7 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -25,7 +25,6 @@ use lsp_types::{ SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, SymbolTag, TextDocumentIdentifier, TextDocumentPositionParams, Url, WorkspaceEdit, }; -use num_format::{Locale, ToFormattedString}; use project_model::TargetKind; use serde::{Deserialize, Serialize}; use serde_json::{json, to_value}; @@ -67,12 +66,8 @@ pub(crate) fn handle_analyzer_status( format_to!( buf, "Loaded {:?} packages across {} workspace{}.\n", - snap.workspaces - .iter() - .map(|w| w.n_packages()) - .sum::() - .to_formatted_string(&Locale::en), - snap.workspaces.len().to_formatted_string(&Locale::en), + snap.workspaces.iter().map(|w| w.n_packages()).sum::(), + snap.workspaces.len(), if snap.workspaces.len() == 1 { "" } else { "s" } ); } From d1821e4b6e0e9f6a84a167caeea883eb565fd3eb Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Mon, 28 Jun 2021 07:31:54 +0100 Subject: [PATCH 09/14] fix all reviews --- .gitignore | 3 +-- crates/ide/Cargo.toml | 1 + crates/ide/src/status.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 8199e35c08..118df746af 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,4 @@ crates/*/target generated_assists.adoc generated_features.adoc generated_diagnostic.adoc -.DS_Store -.glitterrc +.DS_Store \ No newline at end of file diff --git a/crates/ide/Cargo.toml b/crates/ide/Cargo.toml index 3bc07aedf5..0e84473940 100644 --- a/crates/ide/Cargo.toml +++ b/crates/ide/Cargo.toml @@ -21,6 +21,7 @@ pulldown-cmark-to-cmark = "6.0.0" pulldown-cmark = { version = "0.8.0", default-features = false } url = "2.1.1" dot = "0.1.4" + stdx = { path = "../stdx", version = "0.0.0" } syntax = { path = "../syntax", version = "0.0.0" } text_edit = { path = "../text_edit", version = "0.0.0" } diff --git a/crates/ide/src/status.rs b/crates/ide/src/status.rs index 22f1a09091..c256788c3f 100644 --- a/crates/ide/src/status.rs +++ b/crates/ide/src/status.rs @@ -151,7 +151,7 @@ struct LibrarySymbolsStats { impl fmt::Display for LibrarySymbolsStats { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "{} of index symbols", self.size) + write!(fmt, "{} of index symbols ({})", self.size, self.total) } } From 52826171275f2ec0fc4e851c9455c2dd523aa864 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Mon, 28 Jun 2021 17:49:19 +0100 Subject: [PATCH 10/14] trailing line --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 118df746af..7e097c0158 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,4 @@ crates/*/target generated_assists.adoc generated_features.adoc generated_diagnostic.adoc -.DS_Store \ No newline at end of file +.DS_Store From 2e60908fde3000009973f56d6ebfc3ae4d9151de Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Mon, 28 Jun 2021 17:50:24 +0100 Subject: [PATCH 11/14] check if counts should be a thing --- crates/ide/src/status.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/crates/ide/src/status.rs b/crates/ide/src/status.rs index c256788c3f..6cde06eaa2 100644 --- a/crates/ide/src/status.rs +++ b/crates/ide/src/status.rs @@ -12,6 +12,7 @@ use ide_db::{ use itertools::Itertools; use profile::{memory_usage, Bytes}; use rustc_hash::FxHashMap; +use std::env; use stdx::format_to; use syntax::{ast, Parse, SyntaxNode}; @@ -40,15 +41,17 @@ pub(crate) fn status(db: &RootDatabase, file_id: Option) -> String { format_to!(buf, "{}\n", syntax_tree_stats(db)); format_to!(buf, "{} (Macros)\n", macro_syntax_tree_stats(db)); format_to!(buf, "{} in total\n", memory_usage()); - format_to!( - buf, - "\nCounts:\n{}", - if count.to_string().contains("all counts are zero") { - String::from("All counts are zero\n") - } else { - count.to_string() - } - ); + if env::var("RA_COUNT").is_ok() { + format_to!( + buf, + "\nCounts:\n{}", + if count.to_string().contains("all counts are zero") { + String::from("All counts are zero\n") + } else { + count.to_string() + } + ); + } if let Some(file_id) = file_id { format_to!(buf, "\nFile info:\n"); From 443d2164ef9ce3a67c2dd4c985198b2f11a8e576 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Mon, 28 Jun 2021 17:52:57 +0100 Subject: [PATCH 12/14] remove unneeded ifs --- crates/ide/src/status.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/crates/ide/src/status.rs b/crates/ide/src/status.rs index 6cde06eaa2..cf9849272c 100644 --- a/crates/ide/src/status.rs +++ b/crates/ide/src/status.rs @@ -42,15 +42,7 @@ pub(crate) fn status(db: &RootDatabase, file_id: Option) -> String { format_to!(buf, "{} (Macros)\n", macro_syntax_tree_stats(db)); format_to!(buf, "{} in total\n", memory_usage()); if env::var("RA_COUNT").is_ok() { - format_to!( - buf, - "\nCounts:\n{}", - if count.to_string().contains("all counts are zero") { - String::from("All counts are zero\n") - } else { - count.to_string() - } - ); + format_to!(buf, "\nCounts:\n{}", count.to_string()); } if let Some(file_id) = file_id { From d85fa40d58df2055491ccb04d6e570b9933a0da1 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Tue, 29 Jun 2021 20:32:33 +0100 Subject: [PATCH 13/14] Update crates/ide/src/status.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Laurențiu Nicola --- crates/ide/src/status.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ide/src/status.rs b/crates/ide/src/status.rs index cf9849272c..3ddabaef57 100644 --- a/crates/ide/src/status.rs +++ b/crates/ide/src/status.rs @@ -42,7 +42,7 @@ pub(crate) fn status(db: &RootDatabase, file_id: Option) -> String { format_to!(buf, "{} (Macros)\n", macro_syntax_tree_stats(db)); format_to!(buf, "{} in total\n", memory_usage()); if env::var("RA_COUNT").is_ok() { - format_to!(buf, "\nCounts:\n{}", count.to_string()); + format_to!(buf, "\nCounts:\n{}", count); } if let Some(file_id) = file_id { From 4d8fe6208eb5543183bc8668ca4fefef50a67bf9 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Tue, 29 Jun 2021 20:34:52 +0100 Subject: [PATCH 14/14] fix --- crates/ide/src/status.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/ide/src/status.rs b/crates/ide/src/status.rs index 3ddabaef57..d11c2c35e4 100644 --- a/crates/ide/src/status.rs +++ b/crates/ide/src/status.rs @@ -35,14 +35,13 @@ fn macro_syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats { // image::https://user-images.githubusercontent.com/48062697/113065584-05f34500-91b1-11eb-98cc-5c196f76be7f.gif[] pub(crate) fn status(db: &RootDatabase, file_id: Option) -> String { let mut buf = String::new(); - let count = profile::countme::get_all(); format_to!(buf, "{}\n", FileTextQuery.in_db(db).entries::()); format_to!(buf, "{}\n", LibrarySymbolsQuery.in_db(db).entries::()); format_to!(buf, "{}\n", syntax_tree_stats(db)); format_to!(buf, "{} (Macros)\n", macro_syntax_tree_stats(db)); format_to!(buf, "{} in total\n", memory_usage()); if env::var("RA_COUNT").is_ok() { - format_to!(buf, "\nCounts:\n{}", count); + format_to!(buf, "\nCounts:\n{}", profile::countme::get_all()); } if let Some(file_id) = file_id {