mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
introduce hir debugging infra
This is to make debugging rust-analyzer easier. The idea is that `dbg!(krate.debug(db))` will print the actual, fuzzy crate name, instead of precise ID. Debug printing infra is a separate thing, to make sure that the actual hir doesn't have access to global information. Do not use `.debug` for `log::` logging: debugging executes queries, and might introduce unneded dependencies to the crate graph
This commit is contained in:
parent
734a43e95a
commit
ef2b84ddf1
11 changed files with 166 additions and 18 deletions
|
@ -2,7 +2,7 @@ use std::{fmt, sync::Arc, time};
|
|||
|
||||
use ra_db::{
|
||||
salsa::{Database, Durability, SweepStrategy},
|
||||
CrateGraph, FileId, SourceDatabase, SourceRoot, SourceRootId,
|
||||
CrateGraph, CrateId, FileId, SourceDatabase, SourceRoot, SourceRootId,
|
||||
};
|
||||
use ra_prof::{memory_usage, profile, Bytes};
|
||||
use ra_syntax::SourceFile;
|
||||
|
@ -11,7 +11,7 @@ use relative_path::RelativePathBuf;
|
|||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::{
|
||||
db::RootDatabase,
|
||||
db::{DebugData, RootDatabase},
|
||||
status::syntax_tree_stats,
|
||||
symbol_index::{SymbolIndex, SymbolsDatabase},
|
||||
};
|
||||
|
@ -23,6 +23,7 @@ pub struct AnalysisChange {
|
|||
files_changed: Vec<(FileId, Arc<String>)>,
|
||||
libraries_added: Vec<LibraryData>,
|
||||
crate_graph: Option<CrateGraph>,
|
||||
debug_data: DebugData,
|
||||
}
|
||||
|
||||
impl fmt::Debug for AnalysisChange {
|
||||
|
@ -83,6 +84,14 @@ impl AnalysisChange {
|
|||
pub fn set_crate_graph(&mut self, graph: CrateGraph) {
|
||||
self.crate_graph = Some(graph);
|
||||
}
|
||||
|
||||
pub fn set_debug_crate_name(&mut self, crate_id: CrateId, name: String) {
|
||||
self.debug_data.crate_names.insert(crate_id, name);
|
||||
}
|
||||
|
||||
pub fn set_debug_root_path(&mut self, source_root_id: SourceRootId, path: String) {
|
||||
self.debug_data.root_paths.insert(source_root_id, path);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -200,6 +209,8 @@ impl RootDatabase {
|
|||
if let Some(crate_graph) = change.crate_graph {
|
||||
self.set_crate_graph_with_durability(Arc::new(crate_graph), Durability::HIGH)
|
||||
}
|
||||
|
||||
Arc::make_mut(&mut self.debug_data).merge(change.debug_data)
|
||||
}
|
||||
|
||||
fn apply_root_change(&mut self, root_id: SourceRootId, root_change: RootChange) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue