1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
use hir::{EditionedFileId, Semantics, db::DefDatabase}; use ide_db::{FileId, RootDatabase}; // Feature: Debug ItemTree // // Displays the ItemTree of the currently open file, for debugging. // // | Editor | Action Name | // |---------|-------------| // | VS Code | **rust-analyzer: Debug ItemTree** | pub(crate) fn view_item_tree(db: &RootDatabase, file_id: FileId) -> String { let sema = Semantics::new(db); let file_id = sema .attach_first_edition(file_id) .unwrap_or_else(|| EditionedFileId::current_edition(db, file_id)); db.file_item_tree(file_id.into()).pretty_print(db, file_id.edition(db)) }