diff options
author | Edwin Cheng <[email protected]> | 2019-11-10 03:03:24 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-11-11 06:13:31 +0000 |
commit | c46768d13dd34bbe878cc62eca4af873ffbb7c22 (patch) | |
tree | 2354a9f6aaf7d09cae9c386f4330852b10cd5d9a /crates/ra_hir/src | |
parent | defc7ad772123a449f7cc384dd46d88c3a45fb53 (diff) |
Add basic bultin macro infrastructure
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/code_model/src.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs index 6d116ee75..c4e62f799 100644 --- a/crates/ra_hir/src/code_model/src.rs +++ b/crates/ra_hir/src/code_model/src.rs | |||
@@ -6,8 +6,8 @@ use crate::{ | |||
6 | adt::VariantDef, | 6 | adt::VariantDef, |
7 | db::{AstDatabase, DefDatabase, HirDatabase}, | 7 | db::{AstDatabase, DefDatabase, HirDatabase}, |
8 | ids::AstItemDef, | 8 | ids::AstItemDef, |
9 | Const, Either, Enum, EnumVariant, FieldSource, Function, HasBody, HirFileId, MacroDef, Module, | 9 | Const, Either, Enum, EnumVariant, FieldSource, Function, HasBody, HirFileId, MacroDef, |
10 | ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union, | 10 | MacroDefId, Module, ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union, |
11 | }; | 11 | }; |
12 | 12 | ||
13 | pub use hir_expand::Source; | 13 | pub use hir_expand::Source; |
@@ -140,10 +140,15 @@ impl HasSource for TypeAlias { | |||
140 | self.id.source(db) | 140 | self.id.source(db) |
141 | } | 141 | } |
142 | } | 142 | } |
143 | |||
143 | impl HasSource for MacroDef { | 144 | impl HasSource for MacroDef { |
144 | type Ast = ast::MacroCall; | 145 | type Ast = ast::MacroCall; |
145 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::MacroCall> { | 146 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::MacroCall> { |
146 | Source { file_id: self.id.ast_id.file_id(), ast: self.id.ast_id.to_node(db) } | 147 | let ast_id = match self.id { |
148 | MacroDefId::DeclarativeMacro(it) => it.ast_id, | ||
149 | MacroDefId::BuiltinMacro(it) => it.ast_id, | ||
150 | }; | ||
151 | Source { file_id: ast_id.file_id(), ast: ast_id.to_node(db) } | ||
147 | } | 152 | } |
148 | } | 153 | } |
149 | 154 | ||