2024-07-17 15:35:40 +00:00
|
|
|
use hir::{db::DefDatabase, Semantics};
|
|
|
|
use ide_db::{FileId, RootDatabase};
|
|
|
|
use span::EditionedFileId;
|
2021-05-21 21:59:52 +00:00
|
|
|
|
|
|
|
// Feature: Debug ItemTree
|
|
|
|
//
|
|
|
|
// Displays the ItemTree of the currently open file, for debugging.
|
|
|
|
//
|
|
|
|
// |===
|
|
|
|
// | Editor | Action Name
|
|
|
|
//
|
2022-08-01 11:47:09 +00:00
|
|
|
// | VS Code | **rust-analyzer: Debug ItemTree**
|
2021-05-21 21:59:52 +00:00
|
|
|
// |===
|
|
|
|
pub(crate) fn view_item_tree(db: &RootDatabase, file_id: FileId) -> String {
|
2024-07-17 15:35:40 +00:00
|
|
|
let sema = Semantics::new(db);
|
|
|
|
let file_id = sema
|
|
|
|
.attach_first_edition(file_id)
|
|
|
|
.unwrap_or_else(|| EditionedFileId::current_edition(file_id));
|
2024-08-15 23:36:24 +00:00
|
|
|
db.file_item_tree(file_id.into()).pretty_print(db, file_id.edition())
|
2021-05-21 21:59:52 +00:00
|
|
|
}
|