From 0ba7e2eaebf335dbc31b5d6dbc9c354737c7fe54 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 23 Jan 2019 00:15:03 +0300 Subject: ad status command --- crates/ra_ide_api/src/lib.rs | 6 ++++++ crates/ra_ide_api/src/status.rs | 15 +++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 crates/ra_ide_api/src/status.rs (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index a09a8f926..3c53e75ac 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs @@ -15,6 +15,7 @@ pub mod mock_analysis; mod symbol_index; mod navigation_target; +mod status; mod completion; mod runnables; mod goto_definition; @@ -293,6 +294,11 @@ pub struct Analysis { } impl Analysis { + /// Debug info about the current state of the analysis + pub fn status(&self) -> String { + status::status(&*self.db) + } + /// Gets the text of the source file. pub fn file_text(&self, file_id: FileId) -> Arc { self.db.file_text(file_id) diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs new file mode 100644 index 000000000..d3e04be23 --- /dev/null +++ b/crates/ra_ide_api/src/status.rs @@ -0,0 +1,15 @@ +use ra_db::{ + LocationIntener, SourceFileQuery, + salsa::{Database, debug::DebugQueryTable}, +}; + +use crate::db::RootDatabase; + +pub(crate) fn status(db: &RootDatabase) -> String { + let n_parsed_files = db.query(SourceFileQuery).keys::>().len(); + let n_defs = { + let interner: &LocationIntener = db.as_ref(); + interner.len() + }; + format!("#n_parsed_files {}\n#n_defs {}\n", n_parsed_files, n_defs) +} -- cgit v1.2.3