diff options
Diffstat (limited to 'crates/hir_def/src/item_tree.rs')
-rw-r--r-- | crates/hir_def/src/item_tree.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/hir_def/src/item_tree.rs b/crates/hir_def/src/item_tree.rs index 8a1121bbd..7eb388bae 100644 --- a/crates/hir_def/src/item_tree.rs +++ b/crates/hir_def/src/item_tree.rs | |||
@@ -672,6 +672,24 @@ impl ModItem { | |||
672 | pub fn downcast<N: ItemTreeNode>(self) -> Option<FileItemTreeId<N>> { | 672 | pub fn downcast<N: ItemTreeNode>(self) -> Option<FileItemTreeId<N>> { |
673 | N::id_from_mod_item(self) | 673 | N::id_from_mod_item(self) |
674 | } | 674 | } |
675 | |||
676 | pub fn ast_id(&self, tree: &ItemTree) -> FileAstId<ast::Item> { | ||
677 | match self { | ||
678 | ModItem::Import(it) => tree[it.index].ast_id().upcast(), | ||
679 | ModItem::ExternCrate(it) => tree[it.index].ast_id().upcast(), | ||
680 | ModItem::Function(it) => tree[it.index].ast_id().upcast(), | ||
681 | ModItem::Struct(it) => tree[it.index].ast_id().upcast(), | ||
682 | ModItem::Union(it) => tree[it.index].ast_id().upcast(), | ||
683 | ModItem::Enum(it) => tree[it.index].ast_id().upcast(), | ||
684 | ModItem::Const(it) => tree[it.index].ast_id().upcast(), | ||
685 | ModItem::Static(it) => tree[it.index].ast_id().upcast(), | ||
686 | ModItem::Trait(it) => tree[it.index].ast_id().upcast(), | ||
687 | ModItem::Impl(it) => tree[it.index].ast_id().upcast(), | ||
688 | ModItem::TypeAlias(it) => tree[it.index].ast_id().upcast(), | ||
689 | ModItem::Mod(it) => tree[it.index].ast_id().upcast(), | ||
690 | ModItem::MacroCall(it) => tree[it.index].ast_id().upcast(), | ||
691 | } | ||
692 | } | ||
675 | } | 693 | } |
676 | 694 | ||
677 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] | 695 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] |