aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model_impl.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/code_model_impl.rs')
-rw-r--r--crates/ra_hir/src/code_model_impl.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/ra_hir/src/code_model_impl.rs b/crates/ra_hir/src/code_model_impl.rs
index 1f28fab74..0cea9f7b6 100644
--- a/crates/ra_hir/src/code_model_impl.rs
+++ b/crates/ra_hir/src/code_model_impl.rs
@@ -1,3 +1,18 @@
1mod krate; // `crate` is invalid ident :( 1mod krate; // `crate` is invalid ident :(
2mod module; 2mod module;
3pub(crate) mod function; 3pub(crate) mod function;
4
5use ra_syntax::{AstNode, TreeArc};
6
7use crate::{HirDatabase, DefId, HirFileId};
8
9pub(crate) fn def_id_to_ast<N: AstNode>(
10 db: &impl HirDatabase,
11 def_id: DefId,
12) -> (HirFileId, TreeArc<N>) {
13 let (file_id, syntax) = def_id.source(db);
14 let ast = N::cast(&syntax)
15 .unwrap_or_else(|| panic!("def points to wrong source {:?} {:?}", def_id, syntax))
16 .to_owned();
17 (file_id, ast)
18}