aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_expand')
-rw-r--r--crates/ra_hir_expand/src/lib.rs14
-rw-r--r--crates/ra_hir_expand/src/test_db.rs4
2 files changed, 16 insertions, 2 deletions
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs
index 4f3ccf1d0..b6a739cda 100644
--- a/crates/ra_hir_expand/src/lib.rs
+++ b/crates/ra_hir_expand/src/lib.rs
@@ -135,6 +135,16 @@ pub struct MacroDefId {
135 pub kind: MacroDefKind, 135 pub kind: MacroDefKind,
136} 136}
137 137
138impl MacroDefId {
139 pub fn as_call_id(
140 self,
141 db: &dyn db::AstDatabase,
142 ast_id: AstId<ast::MacroCall>,
143 ) -> MacroCallId {
144 db.intern_macro(MacroCallLoc { def: self, ast_id })
145 }
146}
147
138#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 148#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
139pub enum MacroDefKind { 149pub enum MacroDefKind {
140 Declarative, 150 Declarative,
@@ -143,8 +153,8 @@ pub enum MacroDefKind {
143 153
144#[derive(Debug, Clone, PartialEq, Eq, Hash)] 154#[derive(Debug, Clone, PartialEq, Eq, Hash)]
145pub struct MacroCallLoc { 155pub struct MacroCallLoc {
146 pub def: MacroDefId, 156 pub(crate) def: MacroDefId,
147 pub ast_id: AstId<ast::MacroCall>, 157 pub(crate) ast_id: AstId<ast::MacroCall>,
148} 158}
149 159
150impl MacroCallId { 160impl MacroCallId {
diff --git a/crates/ra_hir_expand/src/test_db.rs b/crates/ra_hir_expand/src/test_db.rs
index d23e75d9e..918736e2a 100644
--- a/crates/ra_hir_expand/src/test_db.rs
+++ b/crates/ra_hir_expand/src/test_db.rs
@@ -23,6 +23,10 @@ impl salsa::Database for TestDB {
23 &self.runtime 23 &self.runtime
24 } 24 }
25 25
26 fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
27 &mut self.runtime
28 }
29
26 fn salsa_event(&self, event: impl Fn() -> salsa::Event<TestDB>) { 30 fn salsa_event(&self, event: impl Fn() -> salsa::Event<TestDB>) {
27 let mut events = self.events.lock().unwrap(); 31 let mut events = self.events.lock().unwrap();
28 if let Some(events) = &mut *events { 32 if let Some(events) = &mut *events {