aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-10-29 12:22:20 +0000
committerAleksey Kladov <[email protected]>2019-10-29 12:22:20 +0000
commitd095d9273eb2c03d1c28e0122c21fccf4099660e (patch)
treeb11ae8f052d7c6898b754dc16327c490ac410608
parent858dd48af26e851897b2e8d2fbf757f3adfbc92c (diff)
remove unused query
-rw-r--r--crates/ra_hir_expand/src/db.rs15
-rw-r--r--crates/ra_hir_expand/src/lib.rs5
2 files changed, 5 insertions, 15 deletions
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs
index 12aa7ad0e..8b92d4c1f 100644
--- a/crates/ra_hir_expand/src/db.rs
+++ b/crates/ra_hir_expand/src/db.rs
@@ -6,16 +6,14 @@ use ra_prof::profile;
6use ra_syntax::{AstNode, Parse, SyntaxNode}; 6use ra_syntax::{AstNode, Parse, SyntaxNode};
7 7
8use crate::{ 8use crate::{
9 ast_id_map::{AstIdMap, ErasedFileAstId}, 9 ast_id_map::AstIdMap, HirFileId, HirFileIdRepr, MacroCallId, MacroCallLoc, MacroDefId,
10 HirFileId, HirFileIdRepr, MacroCallId, MacroCallLoc, MacroDefId, MacroFile, MacroFileKind, 10 MacroFile, MacroFileKind,
11}; 11};
12 12
13// FIXME: rename to ExpandDatabase 13// FIXME: rename to ExpandDatabase
14#[salsa::query_group(AstDatabaseStorage)] 14#[salsa::query_group(AstDatabaseStorage)]
15pub trait AstDatabase: SourceDatabase { 15pub trait AstDatabase: SourceDatabase {
16 fn ast_id_map(&self, file_id: HirFileId) -> Arc<AstIdMap>; 16 fn ast_id_map(&self, file_id: HirFileId) -> Arc<AstIdMap>;
17 #[salsa::transparent]
18 fn ast_id_to_node(&self, file_id: HirFileId, ast_id: ErasedFileAstId) -> SyntaxNode;
19 17
20 #[salsa::transparent] 18 #[salsa::transparent]
21 fn parse_or_expand(&self, file_id: HirFileId) -> Option<SyntaxNode>; 19 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
34 Arc::new(map) 32 Arc::new(map)
35} 33}
36 34
37pub(crate) fn ast_id_to_node(
38 db: &impl AstDatabase,
39 file_id: HirFileId,
40 ast_id: ErasedFileAstId,
41) -> SyntaxNode {
42 let node = db.parse_or_expand(file_id).unwrap();
43 db.ast_id_map(file_id)[ast_id].to_node(&node)
44}
45
46pub(crate) fn macro_def(db: &impl AstDatabase, id: MacroDefId) -> Option<Arc<MacroRules>> { 35pub(crate) fn macro_def(db: &impl AstDatabase, id: MacroDefId) -> Option<Arc<MacroRules>> {
47 let macro_call = id.ast_id.to_node(db); 36 let macro_call = id.ast_id.to_node(db);
48 let arg = macro_call.token_tree()?; 37 let arg = macro_call.token_tree()?;
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs
index 002a5b45a..1fb124374 100644
--- a/crates/ra_hir_expand/src/lib.rs
+++ b/crates/ra_hir_expand/src/lib.rs
@@ -171,7 +171,8 @@ impl<N: AstNode> AstId<N> {
171 } 171 }
172 172
173 pub fn to_node(&self, db: &impl AstDatabase) -> N { 173 pub fn to_node(&self, db: &impl AstDatabase) -> N {
174 let syntax_node = db.ast_id_to_node(self.file_id, self.file_ast_id.into()); 174 let root = db.parse_or_expand(self.file_id).unwrap();
175 N::cast(syntax_node).unwrap() 175 let node = db.ast_id_map(self.file_id)[self.file_ast_id.into()].to_node(&root);
176 N::cast(node).unwrap()
176 } 177 }
177} 178}