aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir_expand/src/db.rs12
-rw-r--r--crates/ra_hir_expand/src/lib.rs6
2 files changed, 9 insertions, 9 deletions
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs
index dc4944c05..a4ee9a529 100644
--- a/crates/ra_hir_expand/src/db.rs
+++ b/crates/ra_hir_expand/src/db.rs
@@ -28,13 +28,13 @@ pub trait AstDatabase: SourceDatabase {
28 fn macro_expand(&self, macro_call: MacroCallId) -> Result<Arc<tt::Subtree>, String>; 28 fn macro_expand(&self, macro_call: MacroCallId) -> Result<Arc<tt::Subtree>, String>;
29} 29}
30 30
31pub(crate) fn ast_id_map(db: &impl AstDatabase, file_id: HirFileId) -> Arc<AstIdMap> { 31pub(crate) fn ast_id_map(db: &dyn AstDatabase, file_id: HirFileId) -> Arc<AstIdMap> {
32 let map = 32 let map =
33 db.parse_or_expand(file_id).map_or_else(AstIdMap::default, |it| AstIdMap::from_source(&it)); 33 db.parse_or_expand(file_id).map_or_else(AstIdMap::default, |it| AstIdMap::from_source(&it));
34 Arc::new(map) 34 Arc::new(map)
35} 35}
36 36
37pub(crate) fn macro_def(db: &impl AstDatabase, id: MacroDefId) -> Option<Arc<MacroRules>> { 37pub(crate) fn macro_def(db: &dyn AstDatabase, id: MacroDefId) -> Option<Arc<MacroRules>> {
38 let macro_call = id.ast_id.to_node(db); 38 let macro_call = id.ast_id.to_node(db);
39 let arg = macro_call.token_tree()?; 39 let arg = macro_call.token_tree()?;
40 let (tt, _) = mbe::ast_to_token_tree(&arg).or_else(|| { 40 let (tt, _) = mbe::ast_to_token_tree(&arg).or_else(|| {
@@ -48,7 +48,7 @@ pub(crate) fn macro_def(db: &impl AstDatabase, id: MacroDefId) -> Option<Arc<Mac
48 Some(Arc::new(rules)) 48 Some(Arc::new(rules))
49} 49}
50 50
51pub(crate) fn macro_arg(db: &impl AstDatabase, id: MacroCallId) -> Option<Arc<tt::Subtree>> { 51pub(crate) fn macro_arg(db: &dyn AstDatabase, id: MacroCallId) -> Option<Arc<tt::Subtree>> {
52 let loc = db.lookup_intern_macro(id); 52 let loc = db.lookup_intern_macro(id);
53 let macro_call = loc.ast_id.to_node(db); 53 let macro_call = loc.ast_id.to_node(db);
54 let arg = macro_call.token_tree()?; 54 let arg = macro_call.token_tree()?;
@@ -57,7 +57,7 @@ pub(crate) fn macro_arg(db: &impl AstDatabase, id: MacroCallId) -> Option<Arc<tt
57} 57}
58 58
59pub(crate) fn macro_expand( 59pub(crate) fn macro_expand(
60 db: &impl AstDatabase, 60 db: &dyn AstDatabase,
61 id: MacroCallId, 61 id: MacroCallId,
62) -> Result<Arc<tt::Subtree>, String> { 62) -> Result<Arc<tt::Subtree>, String> {
63 let loc = db.lookup_intern_macro(id); 63 let loc = db.lookup_intern_macro(id);
@@ -73,7 +73,7 @@ pub(crate) fn macro_expand(
73 Ok(Arc::new(tt)) 73 Ok(Arc::new(tt))
74} 74}
75 75
76pub(crate) fn parse_or_expand(db: &impl AstDatabase, file_id: HirFileId) -> Option<SyntaxNode> { 76pub(crate) fn parse_or_expand(db: &dyn AstDatabase, file_id: HirFileId) -> Option<SyntaxNode> {
77 match file_id.0 { 77 match file_id.0 {
78 HirFileIdRepr::FileId(file_id) => Some(db.parse(file_id).tree().syntax().clone()), 78 HirFileIdRepr::FileId(file_id) => Some(db.parse(file_id).tree().syntax().clone()),
79 HirFileIdRepr::MacroFile(macro_file) => { 79 HirFileIdRepr::MacroFile(macro_file) => {
@@ -83,7 +83,7 @@ pub(crate) fn parse_or_expand(db: &impl AstDatabase, file_id: HirFileId) -> Opti
83} 83}
84 84
85pub(crate) fn parse_macro( 85pub(crate) fn parse_macro(
86 db: &impl AstDatabase, 86 db: &dyn AstDatabase,
87 macro_file: MacroFile, 87 macro_file: MacroFile,
88) -> Option<Parse<SyntaxNode>> { 88) -> Option<Parse<SyntaxNode>> {
89 let _p = profile("parse_macro_query"); 89 let _p = profile("parse_macro_query");
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs
index 9100bd15c..749227465 100644
--- a/crates/ra_hir_expand/src/lib.rs
+++ b/crates/ra_hir_expand/src/lib.rs
@@ -63,7 +63,7 @@ impl From<MacroFile> for HirFileId {
63impl HirFileId { 63impl HirFileId {
64 /// For macro-expansion files, returns the file original source file the 64 /// For macro-expansion files, returns the file original source file the
65 /// expansion originated from. 65 /// expansion originated from.
66 pub fn original_file(self, db: &impl AstDatabase) -> FileId { 66 pub fn original_file(self, db: &dyn AstDatabase) -> FileId {
67 match self.0 { 67 match self.0 {
68 HirFileIdRepr::FileId(file_id) => file_id, 68 HirFileIdRepr::FileId(file_id) => file_id,
69 HirFileIdRepr::MacroFile(macro_file) => { 69 HirFileIdRepr::MacroFile(macro_file) => {
@@ -74,7 +74,7 @@ impl HirFileId {
74 } 74 }
75 75
76 /// Get the crate which the macro lives in, if it is a macro file. 76 /// Get the crate which the macro lives in, if it is a macro file.
77 pub fn macro_crate(self, db: &impl AstDatabase) -> Option<CrateId> { 77 pub fn macro_crate(self, db: &dyn AstDatabase) -> Option<CrateId> {
78 match self.0 { 78 match self.0 {
79 HirFileIdRepr::FileId(_) => None, 79 HirFileIdRepr::FileId(_) => None,
80 HirFileIdRepr::MacroFile(macro_file) => { 80 HirFileIdRepr::MacroFile(macro_file) => {
@@ -160,7 +160,7 @@ impl<N: AstNode> AstId<N> {
160 self.file_id 160 self.file_id
161 } 161 }
162 162
163 pub fn to_node(&self, db: &impl AstDatabase) -> N { 163 pub fn to_node(&self, db: &dyn AstDatabase) -> N {
164 let root = db.parse_or_expand(self.file_id).unwrap(); 164 let root = db.parse_or_expand(self.file_id).unwrap();
165 db.ast_id_map(self.file_id).get(self.file_ast_id).to_node(&root) 165 db.ast_id_map(self.file_id).get(self.file_ast_id).to_node(&root)
166 } 166 }