diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-22 22:25:22 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-22 22:25:22 +0000 |
commit | f90783fc5309e1835b22aa65d071efb9cf3eb9df (patch) | |
tree | f60d21521d667e46bb7596c74b0064f3650798e2 /crates/ra_ide_api | |
parent | e08df3219d7a06b1e38c632e7f13967fb540769b (diff) | |
parent | c0dba92b7fec667bda1c1a1af258ef37ee8cbf54 (diff) |
Merge #602
602: add status command r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/status.rs | 15 |
2 files changed, 21 insertions, 0 deletions
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; | |||
15 | mod symbol_index; | 15 | mod symbol_index; |
16 | mod navigation_target; | 16 | mod navigation_target; |
17 | 17 | ||
18 | mod status; | ||
18 | mod completion; | 19 | mod completion; |
19 | mod runnables; | 20 | mod runnables; |
20 | mod goto_definition; | 21 | mod goto_definition; |
@@ -293,6 +294,11 @@ pub struct Analysis { | |||
293 | } | 294 | } |
294 | 295 | ||
295 | impl Analysis { | 296 | impl Analysis { |
297 | /// Debug info about the current state of the analysis | ||
298 | pub fn status(&self) -> String { | ||
299 | status::status(&*self.db) | ||
300 | } | ||
301 | |||
296 | /// Gets the text of the source file. | 302 | /// Gets the text of the source file. |
297 | pub fn file_text(&self, file_id: FileId) -> Arc<String> { | 303 | pub fn file_text(&self, file_id: FileId) -> Arc<String> { |
298 | self.db.file_text(file_id) | 304 | 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 @@ | |||
1 | use ra_db::{ | ||
2 | LocationIntener, SourceFileQuery, | ||
3 | salsa::{Database, debug::DebugQueryTable}, | ||
4 | }; | ||
5 | |||
6 | use crate::db::RootDatabase; | ||
7 | |||
8 | pub(crate) fn status(db: &RootDatabase) -> String { | ||
9 | let n_parsed_files = db.query(SourceFileQuery).keys::<Vec<_>>().len(); | ||
10 | let n_defs = { | ||
11 | let interner: &LocationIntener<hir::DefLoc, hir::DefId> = db.as_ref(); | ||
12 | interner.len() | ||
13 | }; | ||
14 | format!("#n_parsed_files {}\n#n_defs {}\n", n_parsed_files, n_defs) | ||
15 | } | ||