mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
add AstDatabase
This commit is contained in:
parent
8256dfdd71
commit
5af9e475f4
17 changed files with 186 additions and 98 deletions
|
@ -3,7 +3,7 @@ use std::{marker::PhantomData, sync::Arc, hash::{Hash, Hasher}};
|
|||
use ra_arena::{Arena, RawId, impl_arena_id};
|
||||
use ra_syntax::{SyntaxNodePtr, TreeArc, SyntaxNode, AstNode, ast};
|
||||
|
||||
use crate::{HirFileId, DefDatabase};
|
||||
use crate::{HirFileId, AstDatabase};
|
||||
|
||||
/// `AstId` points to an AST node in any file.
|
||||
///
|
||||
|
@ -38,7 +38,7 @@ impl<N: AstNode> AstId<N> {
|
|||
self.file_id
|
||||
}
|
||||
|
||||
pub(crate) fn to_node(&self, db: &impl DefDatabase) -> TreeArc<N> {
|
||||
pub(crate) fn to_node(&self, db: &impl AstDatabase) -> TreeArc<N> {
|
||||
let syntax_node = db.ast_id_to_node(self.file_id, self.file_ast_id.raw);
|
||||
N::cast(&syntax_node).unwrap().to_owned()
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ pub struct AstIdMap {
|
|||
}
|
||||
|
||||
impl AstIdMap {
|
||||
pub(crate) fn ast_id_map_query(db: &impl DefDatabase, file_id: HirFileId) -> Arc<AstIdMap> {
|
||||
pub(crate) fn ast_id_map_query(db: &impl AstDatabase, file_id: HirFileId) -> Arc<AstIdMap> {
|
||||
let map = if let Some(node) = db.parse_or_expand(file_id) {
|
||||
AstIdMap::from_source(&*node)
|
||||
} else {
|
||||
|
@ -97,7 +97,7 @@ impl AstIdMap {
|
|||
}
|
||||
|
||||
pub(crate) fn file_item_query(
|
||||
db: &impl DefDatabase,
|
||||
db: &impl AstDatabase,
|
||||
file_id: HirFileId,
|
||||
ast_id: ErasedFileAstId,
|
||||
) -> TreeArc<SyntaxNode> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue