diff options
author | Aleksey Kladov <[email protected]> | 2019-01-01 15:11:04 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-01 19:15:35 +0000 |
commit | b2fec18098b6a99613012d185801fed72e424997 (patch) | |
tree | 5ee6cde2ebd31d18f8fda189ca3709a01fa65dee /crates/ra_analysis/src/macros.rs | |
parent | 57030f587bb0bbe4dea9a97016b4e0f49a7ef5f3 (diff) |
move more macros to hir
Diffstat (limited to 'crates/ra_analysis/src/macros.rs')
-rw-r--r-- | crates/ra_analysis/src/macros.rs | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/crates/ra_analysis/src/macros.rs b/crates/ra_analysis/src/macros.rs deleted file mode 100644 index 21ec36cd6..000000000 --- a/crates/ra_analysis/src/macros.rs +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | /// Begining of macro expansion. | ||
2 | /// | ||
3 | /// This code should be moved out of ra_analysis into hir (?) ideally. | ||
4 | use std::sync::Arc; | ||
5 | |||
6 | use ra_syntax::{ast, AstNode, TextUnit}; | ||
7 | use hir::MacroDatabase; | ||
8 | |||
9 | use crate::{db::RootDatabase, FileId}; | ||
10 | |||
11 | pub(crate) fn expand( | ||
12 | db: &RootDatabase, | ||
13 | _file_id: FileId, | ||
14 | macro_call: ast::MacroCall, | ||
15 | ) -> Option<(TextUnit, Arc<hir::MacroExpansion>)> { | ||
16 | let path = macro_call.path()?; | ||
17 | if path.qualifier().is_some() { | ||
18 | return None; | ||
19 | } | ||
20 | let name_ref = path.segment()?.name_ref()?; | ||
21 | if name_ref.text() != "ctry" { | ||
22 | return None; | ||
23 | } | ||
24 | let arg = macro_call.token_tree()?.syntax(); | ||
25 | |||
26 | let def = hir::MacroDef::CTry; | ||
27 | let input = hir::MacroInput { | ||
28 | text: arg.text().to_string(), | ||
29 | }; | ||
30 | let exp = db.expand_macro(def, input)?; | ||
31 | Some((arg.range().start(), exp)) | ||
32 | } | ||