diff options
Diffstat (limited to 'crates/ra_analysis/src/hir/function/imp.rs')
-rw-r--r-- | crates/ra_analysis/src/hir/function/imp.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/crates/ra_analysis/src/hir/function/imp.rs b/crates/ra_analysis/src/hir/function/imp.rs new file mode 100644 index 000000000..cd573a47f --- /dev/null +++ b/crates/ra_analysis/src/hir/function/imp.rs | |||
@@ -0,0 +1,21 @@ | |||
1 | use std::sync::Arc; | ||
2 | |||
3 | use ra_syntax::ast::{AstNode, FnDef, FnDefNode}; | ||
4 | |||
5 | use crate::hir::{ | ||
6 | function::{FnId, FnScopes}, | ||
7 | DescriptorDatabase, | ||
8 | }; | ||
9 | |||
10 | /// Resolve `FnId` to the corresponding `SyntaxNode` | ||
11 | pub(crate) fn fn_syntax(db: &impl DescriptorDatabase, fn_id: FnId) -> FnDefNode { | ||
12 | let ptr = db.id_maps().fn_ptr(fn_id); | ||
13 | let syntax = db.resolve_syntax_ptr(ptr); | ||
14 | FnDef::cast(syntax.borrowed()).unwrap().owned() | ||
15 | } | ||
16 | |||
17 | pub(crate) fn fn_scopes(db: &impl DescriptorDatabase, fn_id: FnId) -> Arc<FnScopes> { | ||
18 | let syntax = db._fn_syntax(fn_id); | ||
19 | let res = FnScopes::new(syntax.borrowed()); | ||
20 | Arc::new(res) | ||
21 | } | ||