aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-09 10:14:10 +0000
committerAleksey Kladov <[email protected]>2019-11-09 10:14:10 +0000
commit70f2a21b55c1b09e575798a75807e13991f2cfec (patch)
treeb0b01d1397542585802a3622fdf9491e20fa8c0b /crates/ra_hir_expand/src
parentf6c40c09e0b5afa1b341ab7675c815862e07d22a (diff)
Remove typed macro parsing API
We do type-erasure on every path anyway, so it doesn't make much sense to duplicate this function for every type
Diffstat (limited to 'crates/ra_hir_expand/src')
-rw-r--r--crates/ra_hir_expand/src/db.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs
index b789c6e7b..b4dafe1d8 100644
--- a/crates/ra_hir_expand/src/db.rs
+++ b/crates/ra_hir_expand/src/db.rs
@@ -4,6 +4,7 @@ use std::sync::Arc;
4 4
5use mbe::MacroRules; 5use mbe::MacroRules;
6use ra_db::{salsa, SourceDatabase}; 6use ra_db::{salsa, SourceDatabase};
7use ra_parser::FragmentKind;
7use ra_prof::profile; 8use ra_prof::profile;
8use ra_syntax::{AstNode, Parse, SyntaxNode}; 9use ra_syntax::{AstNode, Parse, SyntaxNode};
9 10
@@ -108,12 +109,10 @@ pub(crate) fn parse_macro(
108 }) 109 })
109 .ok()?; 110 .ok()?;
110 111
111 match macro_file.macro_file_kind { 112 let fragment_kind = match macro_file.macro_file_kind {
112 MacroFileKind::Items => { 113 MacroFileKind::Items => FragmentKind::Items,
113 mbe::token_tree_to_items(&tt).ok().map(|(p, map)| (p.to_syntax(), Arc::new(map))) 114 MacroFileKind::Expr => FragmentKind::Expr,
114 } 115 };
115 MacroFileKind::Expr => { 116 let (parse, rev_token_map) = mbe::token_tree_to_syntax_node(&tt, fragment_kind).ok()?;
116 mbe::token_tree_to_expr(&tt).ok().map(|(p, map)| (p.to_syntax(), Arc::new(map))) 117 Some((parse, Arc::new(rev_token_map)))
117 }
118 }
119} 118}