From ef2b84ddf119c950272c5f1eb321f3f9e90bedd4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 8 Sep 2019 09:48:45 +0300 Subject: 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 --- crates/ra_lsp_server/Cargo.toml | 1 + crates/ra_lsp_server/src/world.rs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index 46a0f958c..677d81835 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml @@ -18,6 +18,7 @@ parking_lot = "0.9.0" jod-thread = "0.1.0" ra_vfs = "0.4.0" ra_syntax = { path = "../ra_syntax" } +ra_db = { path = "../ra_db" } ra_text_edit = { path = "../ra_text_edit" } ra_ide_api = { path = "../ra_ide_api" } lsp-server = "0.2.0" diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 086ecd587..232409c3b 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -92,6 +92,7 @@ impl WorldState { let vfs_root_path = vfs.root2path(r); let is_local = folder_roots.iter().any(|it| vfs_root_path.starts_with(it)); change.add_root(SourceRootId(r.0), is_local); + change.set_debug_root_path(SourceRootId(r.0), vfs_root_path.display().to_string()); } // Create crate graph from all the workspaces @@ -101,7 +102,11 @@ impl WorldState { vfs_file.map(|f| FileId(f.0)) }; for ws in workspaces.iter() { - crate_graph.extend(ws.to_crate_graph(&mut load)); + let (graph, crate_names) = ws.to_crate_graph(&mut load); + let shift = crate_graph.extend(graph); + for (crate_id, name) in crate_names { + change.set_debug_crate_name(crate_id.shift(shift), name) + } } change.set_crate_graph(crate_graph); -- cgit v1.2.3