mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 21:28:51 +00:00
less generics
This commit is contained in:
parent
6bf7faf315
commit
858dd48af2
2 changed files with 9 additions and 6 deletions
|
@ -75,17 +75,19 @@ impl AstIdMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ast_id<N: AstNode>(&self, item: &N) -> FileAstId<N> {
|
pub fn ast_id<N: AstNode>(&self, item: &N) -> FileAstId<N> {
|
||||||
let ptr = SyntaxNodePtr::new(item.syntax());
|
let raw = self.erased_ast_id(item.syntax());
|
||||||
let raw = match self.arena.iter().find(|(_id, i)| **i == ptr) {
|
FileAstId { raw, _ty: PhantomData }
|
||||||
|
}
|
||||||
|
fn erased_ast_id(&self, item: &SyntaxNode) -> ErasedFileAstId {
|
||||||
|
let ptr = SyntaxNodePtr::new(item);
|
||||||
|
match self.arena.iter().find(|(_id, i)| **i == ptr) {
|
||||||
Some((it, _)) => it,
|
Some((it, _)) => it,
|
||||||
None => panic!(
|
None => panic!(
|
||||||
"Can't find {:?} in AstIdMap:\n{:?}",
|
"Can't find {:?} in AstIdMap:\n{:?}",
|
||||||
item.syntax(),
|
item,
|
||||||
self.arena.iter().map(|(_id, i)| i).collect::<Vec<_>>(),
|
self.arena.iter().map(|(_id, i)| i).collect::<Vec<_>>(),
|
||||||
),
|
),
|
||||||
};
|
}
|
||||||
|
|
||||||
FileAstId { raw, _ty: PhantomData }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn alloc(&mut self, item: &SyntaxNode) -> ErasedFileAstId {
|
fn alloc(&mut self, item: &SyntaxNode) -> ErasedFileAstId {
|
||||||
|
|
|
@ -10,6 +10,7 @@ use crate::{
|
||||||
HirFileId, HirFileIdRepr, MacroCallId, MacroCallLoc, MacroDefId, MacroFile, MacroFileKind,
|
HirFileId, HirFileIdRepr, MacroCallId, MacroCallLoc, MacroDefId, MacroFile, MacroFileKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// FIXME: rename to ExpandDatabase
|
||||||
#[salsa::query_group(AstDatabaseStorage)]
|
#[salsa::query_group(AstDatabaseStorage)]
|
||||||
pub trait AstDatabase: SourceDatabase {
|
pub trait AstDatabase: SourceDatabase {
|
||||||
fn ast_id_map(&self, file_id: HirFileId) -> Arc<AstIdMap>;
|
fn ast_id_map(&self, file_id: HirFileId) -> Arc<AstIdMap>;
|
||||||
|
|
Loading…
Reference in a new issue