aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir_expand/src/ast_id_map.rs14
-rw-r--r--crates/ra_hir_expand/src/db.rs1
2 files changed, 9 insertions, 6 deletions
diff --git a/crates/ra_hir_expand/src/ast_id_map.rs b/crates/ra_hir_expand/src/ast_id_map.rs
index c3b389102..2f43abe15 100644
--- a/crates/ra_hir_expand/src/ast_id_map.rs
+++ b/crates/ra_hir_expand/src/ast_id_map.rs
@@ -75,17 +75,19 @@ impl AstIdMap {
75 } 75 }
76 76
77 pub fn ast_id<N: AstNode>(&self, item: &N) -> FileAstId<N> { 77 pub fn ast_id<N: AstNode>(&self, item: &N) -> FileAstId<N> {
78 let ptr = SyntaxNodePtr::new(item.syntax()); 78 let raw = self.erased_ast_id(item.syntax());
79 let raw = match self.arena.iter().find(|(_id, i)| **i == ptr) { 79 FileAstId { raw, _ty: PhantomData }
80 }
81 fn erased_ast_id(&self, item: &SyntaxNode) -> ErasedFileAstId {
82 let ptr = SyntaxNodePtr::new(item);
83 match self.arena.iter().find(|(_id, i)| **i == ptr) {
80 Some((it, _)) => it, 84 Some((it, _)) => it,
81 None => panic!( 85 None => panic!(
82 "Can't find {:?} in AstIdMap:\n{:?}", 86 "Can't find {:?} in AstIdMap:\n{:?}",
83 item.syntax(), 87 item,
84 self.arena.iter().map(|(_id, i)| i).collect::<Vec<_>>(), 88 self.arena.iter().map(|(_id, i)| i).collect::<Vec<_>>(),
85 ), 89 ),
86 }; 90 }
87
88 FileAstId { raw, _ty: PhantomData }
89 } 91 }
90 92
91 fn alloc(&mut self, item: &SyntaxNode) -> ErasedFileAstId { 93 fn alloc(&mut self, item: &SyntaxNode) -> ErasedFileAstId {
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs
index 912599e57..12aa7ad0e 100644
--- a/crates/ra_hir_expand/src/db.rs
+++ b/crates/ra_hir_expand/src/db.rs
@@ -10,6 +10,7 @@ use crate::{
10 HirFileId, HirFileIdRepr, MacroCallId, MacroCallLoc, MacroDefId, MacroFile, MacroFileKind, 10 HirFileId, HirFileIdRepr, MacroCallId, MacroCallLoc, MacroDefId, MacroFile, MacroFileKind,
11}; 11};
12 12
13// FIXME: rename to ExpandDatabase
13#[salsa::query_group(AstDatabaseStorage)] 14#[salsa::query_group(AstDatabaseStorage)]
14pub trait AstDatabase: SourceDatabase { 15pub trait AstDatabase: SourceDatabase {
15 fn ast_id_map(&self, file_id: HirFileId) -> Arc<AstIdMap>; 16 fn ast_id_map(&self, file_id: HirFileId) -> Arc<AstIdMap>;