ad status command

This commit is contained in:
Aleksey Kladov 2019-01-23 00:15:03 +03:00
parent e08df3219d
commit 0ba7e2eaeb
10 changed files with 68 additions and 0 deletions

View file

@ -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<String> {
self.db.file_text(file_id)

View file

@ -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::<Vec<_>>().len();
let n_defs = {
let interner: &LocationIntener<hir::DefLoc, hir::DefId> = db.as_ref();
interner.len()
};
format!("#n_parsed_files {}\n#n_defs {}\n", n_parsed_files, n_defs)
}