aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/expand_macro.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/expand_macro.rs')
-rw-r--r--crates/ra_ide/src/expand_macro.rs25
1 files changed, 13 insertions, 12 deletions
diff --git a/crates/ra_ide/src/expand_macro.rs b/crates/ra_ide/src/expand_macro.rs
index 0f7b6e875..af2783bef 100644
--- a/crates/ra_ide/src/expand_macro.rs
+++ b/crates/ra_ide/src/expand_macro.rs
@@ -1,14 +1,15 @@
1//! This modules implements "expand macro" functionality in the IDE 1//! This modules implements "expand macro" functionality in the IDE
2 2
3use crate::{db::RootDatabase, FilePosition};
4use hir::db::AstDatabase; 3use hir::db::AstDatabase;
5use ra_db::SourceDatabase; 4use ra_db::SourceDatabase;
6use rustc_hash::FxHashMap; 5use ra_ide_db::RootDatabase;
7
8use ra_syntax::{ 6use ra_syntax::{
9 algo::{find_node_at_offset, replace_descendants}, 7 algo::{find_node_at_offset, replace_descendants},
10 ast, AstNode, NodeOrToken, SyntaxElement, SyntaxKind, SyntaxNode, WalkEvent, T, 8 ast, AstNode, NodeOrToken, SyntaxElement, SyntaxKind, SyntaxNode, WalkEvent, T,
11}; 9};
10use rustc_hash::FxHashMap;
11
12use crate::FilePosition;
12 13
13pub struct ExpandedMacro { 14pub struct ExpandedMacro {
14 pub name: String, 15 pub name: String,
@@ -185,7 +186,7 @@ fn some_thing() -> u32 {
185 //- /lib.rs 186 //- /lib.rs
186 macro_rules! match_ast { 187 macro_rules! match_ast {
187 (match $node:ident { $($tt:tt)* }) => { match_ast!(match ($node) { $($tt)* }) }; 188 (match $node:ident { $($tt:tt)* }) => { match_ast!(match ($node) { $($tt)* }) };
188 189
189 (match ($node:expr) { 190 (match ($node:expr) {
190 $( ast::$ast:ident($it:ident) => $res:block, )* 191 $( ast::$ast:ident($it:ident) => $res:block, )*
191 _ => $catch_all:expr $(,)? 192 _ => $catch_all:expr $(,)?
@@ -193,7 +194,7 @@ fn some_thing() -> u32 {
193 $( if let Some($it) = ast::$ast::cast($node.clone()) $res else )* 194 $( if let Some($it) = ast::$ast::cast($node.clone()) $res else )*
194 { $catch_all } 195 { $catch_all }
195 }}; 196 }};
196 } 197 }
197 198
198 fn main() { 199 fn main() {
199 mat<|>ch_ast! { 200 mat<|>ch_ast! {
@@ -227,11 +228,11 @@ fn some_thing() -> u32 {
227 r#" 228 r#"
228 //- /lib.rs 229 //- /lib.rs
229 macro_rules! match_ast { 230 macro_rules! match_ast {
230 (match $node:ident { $($tt:tt)* }) => { match_ast!(match ($node) { $($tt)* }) }; 231 (match $node:ident { $($tt:tt)* }) => { match_ast!(match ($node) { $($tt)* }) };
231 (match ($node:expr) {}) => {{}}; 232 (match ($node:expr) {}) => {{}};
232 } 233 }
233 234
234 fn main() { 235 fn main() {
235 let p = f(|it| { 236 let p = f(|it| {
236 let res = mat<|>ch_ast! { match c {}}; 237 let res = mat<|>ch_ast! { match c {}};
237 Some(res) 238 Some(res)
@@ -254,9 +255,9 @@ fn some_thing() -> u32 {
254 } 255 }
255 macro_rules! foo { 256 macro_rules! foo {
256 () => {bar!()}; 257 () => {bar!()};
257 } 258 }
258 259
259 fn main() { 260 fn main() {
260 let res = fo<|>o!(); 261 let res = fo<|>o!();
261 } 262 }
262 "#, 263 "#,
@@ -277,9 +278,9 @@ fn some_thing() -> u32 {
277 } 278 }
278 macro_rules! foo { 279 macro_rules! foo {
279 () => {$crate::bar!()}; 280 () => {$crate::bar!()};
280 } 281 }
281 282
282 fn main() { 283 fn main() {
283 let res = fo<|>o!(); 284 let res = fo<|>o!();
284 } 285 }
285 "#, 286 "#,