aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand
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
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')
-rw-r--r--crates/ra_hir_expand/Cargo.toml1
-rw-r--r--crates/ra_hir_expand/src/db.rs15
2 files changed, 8 insertions, 8 deletions
diff --git a/crates/ra_hir_expand/Cargo.toml b/crates/ra_hir_expand/Cargo.toml
index 9bf5b7918..8f29bf7d9 100644
--- a/crates/ra_hir_expand/Cargo.toml
+++ b/crates/ra_hir_expand/Cargo.toml
@@ -10,6 +10,7 @@ log = "0.4.5"
10ra_arena = { path = "../ra_arena" } 10ra_arena = { path = "../ra_arena" }
11ra_db = { path = "../ra_db" } 11ra_db = { path = "../ra_db" }
12ra_syntax = { path = "../ra_syntax" } 12ra_syntax = { path = "../ra_syntax" }
13ra_parser = { path = "../ra_parser" }
13ra_prof = { path = "../ra_prof" } 14ra_prof = { path = "../ra_prof" }
14tt = { path = "../ra_tt", package = "ra_tt" } 15tt = { path = "../ra_tt", package = "ra_tt" }
15mbe = { path = "../ra_mbe", package = "ra_mbe" } 16mbe = { path = "../ra_mbe", package = "ra_mbe" }
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}