rust-analyzer/crates/ide/src/view_item_tree.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
620 B
Rust
Raw Normal View History

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 {
let sema = Semantics::new(db);
let file_id = sema
.attach_first_edition(file_id)
.unwrap_or_else(|| EditionedFileId::current_edition(file_id));
db.file_item_tree(file_id.into()).pretty_print(db, file_id.edition())
2021-05-21 21:59:52 +00:00
}