aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/descriptors
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/descriptors')
-rw-r--r--crates/ra_analysis/src/descriptors/function/imp.rs4
-rw-r--r--crates/ra_analysis/src/descriptors/function/mod.rs13
-rw-r--r--crates/ra_analysis/src/descriptors/mod.rs3
3 files changed, 11 insertions, 9 deletions
diff --git a/crates/ra_analysis/src/descriptors/function/imp.rs b/crates/ra_analysis/src/descriptors/function/imp.rs
index a989a04cd..a7257acf9 100644
--- a/crates/ra_analysis/src/descriptors/function/imp.rs
+++ b/crates/ra_analysis/src/descriptors/function/imp.rs
@@ -8,9 +8,9 @@ use crate::descriptors::{
8}; 8};
9 9
10/// Resolve `FnId` to the corresponding `SyntaxNode` 10/// Resolve `FnId` to the corresponding `SyntaxNode`
11/// TODO: this should return something more type-safe then `SyntaxNode`
12pub(crate) fn fn_syntax(db: &impl DescriptorDatabase, fn_id: FnId) -> FnDefNode { 11pub(crate) fn fn_syntax(db: &impl DescriptorDatabase, fn_id: FnId) -> FnDefNode {
13 let syntax = db.resolve_syntax_ptr(fn_id.0); 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() 14 FnDef::cast(syntax.borrowed()).unwrap().owned()
15} 15}
16 16
diff --git a/crates/ra_analysis/src/descriptors/function/mod.rs b/crates/ra_analysis/src/descriptors/function/mod.rs
index d5db28a64..86eee5e93 100644
--- a/crates/ra_analysis/src/descriptors/function/mod.rs
+++ b/crates/ra_analysis/src/descriptors/function/mod.rs
@@ -8,17 +8,18 @@ use ra_syntax::{
8 TextRange, TextUnit, 8 TextRange, TextUnit,
9}; 9};
10 10
11use crate::{syntax_ptr::SyntaxPtr, FileId}; 11use crate::{
12 syntax_ptr::SyntaxPtr, FileId,
13 loc2id::IdDatabase,
14};
12 15
13pub(crate) use self::scope::{resolve_local_name, FnScopes}; 16pub(crate) use self::scope::{resolve_local_name, FnScopes};
14 17pub(crate) use crate::loc2id::FnId;
15#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
16pub(crate) struct FnId(SyntaxPtr);
17 18
18impl FnId { 19impl FnId {
19 pub(crate) fn new(file_id: FileId, fn_def: ast::FnDef) -> FnId { 20 pub(crate) fn get(db: &impl IdDatabase, file_id: FileId, fn_def: ast::FnDef) -> FnId {
20 let ptr = SyntaxPtr::new(file_id, fn_def.syntax()); 21 let ptr = SyntaxPtr::new(file_id, fn_def.syntax());
21 FnId(ptr) 22 db.id_maps().fn_id(ptr)
22 } 23 }
23} 24}
24 25
diff --git a/crates/ra_analysis/src/descriptors/mod.rs b/crates/ra_analysis/src/descriptors/mod.rs
index 56bde3849..d602c4e04 100644
--- a/crates/ra_analysis/src/descriptors/mod.rs
+++ b/crates/ra_analysis/src/descriptors/mod.rs
@@ -13,12 +13,13 @@ use crate::{
13 descriptors::function::{resolve_local_name, FnId, FnScopes}, 13 descriptors::function::{resolve_local_name, FnId, FnScopes},
14 descriptors::module::{ModuleId, ModuleScope, ModuleTree, ModuleSource}, 14 descriptors::module::{ModuleId, ModuleScope, ModuleTree, ModuleSource},
15 input::SourceRootId, 15 input::SourceRootId,
16 loc2id::IdDatabase,
16 syntax_ptr::LocalSyntaxPtr, 17 syntax_ptr::LocalSyntaxPtr,
17 Cancelable, 18 Cancelable,
18}; 19};
19 20
20salsa::query_group! { 21salsa::query_group! {
21 pub(crate) trait DescriptorDatabase: SyntaxDatabase { 22 pub(crate) trait DescriptorDatabase: SyntaxDatabase + IdDatabase {
22 fn module_tree(source_root_id: SourceRootId) -> Cancelable<Arc<ModuleTree>> { 23 fn module_tree(source_root_id: SourceRootId) -> Cancelable<Arc<ModuleTree>> {
23 type ModuleTreeQuery; 24 type ModuleTreeQuery;
24 use fn module::imp::module_tree; 25 use fn module::imp::module_tree;