mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
remove unused query
This commit is contained in:
parent
858dd48af2
commit
d095d9273e
2 changed files with 5 additions and 15 deletions
|
@ -6,16 +6,14 @@ use ra_prof::profile;
|
||||||
use ra_syntax::{AstNode, Parse, SyntaxNode};
|
use ra_syntax::{AstNode, Parse, SyntaxNode};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast_id_map::{AstIdMap, ErasedFileAstId},
|
ast_id_map::AstIdMap, HirFileId, HirFileIdRepr, MacroCallId, MacroCallLoc, MacroDefId,
|
||||||
HirFileId, HirFileIdRepr, MacroCallId, MacroCallLoc, MacroDefId, MacroFile, MacroFileKind,
|
MacroFile, MacroFileKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: rename to ExpandDatabase
|
// 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>;
|
||||||
#[salsa::transparent]
|
|
||||||
fn ast_id_to_node(&self, file_id: HirFileId, ast_id: ErasedFileAstId) -> SyntaxNode;
|
|
||||||
|
|
||||||
#[salsa::transparent]
|
#[salsa::transparent]
|
||||||
fn parse_or_expand(&self, file_id: HirFileId) -> Option<SyntaxNode>;
|
fn parse_or_expand(&self, file_id: HirFileId) -> Option<SyntaxNode>;
|
||||||
|
@ -34,15 +32,6 @@ pub(crate) fn ast_id_map(db: &impl AstDatabase, file_id: HirFileId) -> Arc<AstId
|
||||||
Arc::new(map)
|
Arc::new(map)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn ast_id_to_node(
|
|
||||||
db: &impl AstDatabase,
|
|
||||||
file_id: HirFileId,
|
|
||||||
ast_id: ErasedFileAstId,
|
|
||||||
) -> SyntaxNode {
|
|
||||||
let node = db.parse_or_expand(file_id).unwrap();
|
|
||||||
db.ast_id_map(file_id)[ast_id].to_node(&node)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn macro_def(db: &impl AstDatabase, id: MacroDefId) -> Option<Arc<MacroRules>> {
|
pub(crate) fn macro_def(db: &impl AstDatabase, id: MacroDefId) -> Option<Arc<MacroRules>> {
|
||||||
let macro_call = id.ast_id.to_node(db);
|
let macro_call = id.ast_id.to_node(db);
|
||||||
let arg = macro_call.token_tree()?;
|
let arg = macro_call.token_tree()?;
|
||||||
|
|
|
@ -171,7 +171,8 @@ impl<N: AstNode> AstId<N> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_node(&self, db: &impl AstDatabase) -> N {
|
pub fn to_node(&self, db: &impl AstDatabase) -> N {
|
||||||
let syntax_node = db.ast_id_to_node(self.file_id, self.file_ast_id.into());
|
let root = db.parse_or_expand(self.file_id).unwrap();
|
||||||
N::cast(syntax_node).unwrap()
|
let node = db.ast_id_map(self.file_id)[self.file_ast_id.into()].to_node(&root);
|
||||||
|
N::cast(node).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue