diff --git a/crates/ra_hir/src/macros.rs b/crates/ra_hir/src/macros.rs index 7ca34d43451..cf722087550 100644 --- a/crates/ra_hir/src/macros.rs +++ b/crates/ra_hir/src/macros.rs @@ -19,7 +19,6 @@ // Hard-coded defs for now :-( #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum MacroDef { - CTry, Vec, QueryGroup, } @@ -38,9 +37,7 @@ fn from_call(macro_call: &ast::MacroCall) -> Option<(MacroDef, MacroInput)> { let def = { let path = macro_call.path()?; let name_ref = path.segment()?.name_ref()?; - if name_ref.text() == "ctry" { - MacroDef::CTry - } else if name_ref.text() == "vec" { + if name_ref.text() == "vec" { MacroDef::Vec } else if name_ref.text() == "query_group" { MacroDef::QueryGroup @@ -60,35 +57,10 @@ fn from_call(macro_call: &ast::MacroCall) -> Option<(MacroDef, MacroInput)> { fn expand(self, input: MacroInput) -> Option { match self { - MacroDef::CTry => self.expand_ctry(input), MacroDef::Vec => self.expand_vec(input), MacroDef::QueryGroup => self.expand_query_group(input), } } - fn expand_ctry(self, input: MacroInput) -> Option { - let text = format!( - r" - fn dummy() {{ - match {} {{ - None => return Ok(None), - Some(it) => it, - }} - }}", - input.text - ); - let file = SourceFile::parse(&text); - let match_expr = file.syntax().descendants().find_map(ast::MatchExpr::cast)?; - let match_arg = match_expr.expr()?; - let ptr = SyntaxNodePtr::new(match_arg.syntax()); - let src_range = TextRange::offset_len(0.into(), TextUnit::of_str(&input.text)); - let ranges_map = vec![(src_range, match_arg.syntax().range())]; - let res = MacroExpansion { - text, - ranges_map, - ptr, - }; - Some(res) - } fn expand_vec(self, input: MacroInput) -> Option { let text = format!(r"fn dummy() {{ {}; }}", input.text); let file = SourceFile::parse(&text); diff --git a/crates/ra_ide_api/src/extend_selection.rs b/crates/ra_ide_api/src/extend_selection.rs index cd2ebe471b7..f61feaf1b3c 100644 --- a/crates/ra_ide_api/src/extend_selection.rs +++ b/crates/ra_ide_api/src/extend_selection.rs @@ -47,11 +47,11 @@ fn extend_selection_inside_macros() { let (analysis, frange) = single_file_with_range( " fn main() { - ctry!(foo(|x| <|>x<|>)); + vec![foo(|x| <|>x<|>)]; } ", ); let r = analysis.extend_selection(frange).unwrap(); - assert_eq!(r, TextRange::from_to(51.into(), 56.into())); + assert_eq!(r, TextRange::from_to(50.into(), 55.into())); } } diff --git a/crates/ra_ide_api/src/snapshots/tests__highlight_query_group_macro.snap b/crates/ra_ide_api/src/snapshots/tests__highlight_query_group_macro.snap index 062add08385..0b802ac3dcb 100644 --- a/crates/ra_ide_api/src/snapshots/tests__highlight_query_group_macro.snap +++ b/crates/ra_ide_api/src/snapshots/tests__highlight_query_group_macro.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:45:01.017117100+00:00" -creator: insta@0.4.0 +created: "2019-02-01T07:52:15.689836752+00:00" +creator: insta@0.5.3 expression: "&highlights" -source: "crates\\ra_ide_api\\src\\syntax_highlighting.rs" +source: crates/ra_ide_api/src/syntax_highlighting.rs --- [ HighlightedRange { diff --git a/crates/ra_ide_api/src/snapshots/tests__highlights_code_inside_macros.snap b/crates/ra_ide_api/src/snapshots/tests__highlights_code_inside_macros.snap index fd8265abb79..ae8923e75f1 100644 --- a/crates/ra_ide_api/src/snapshots/tests__highlights_code_inside_macros.snap +++ b/crates/ra_ide_api/src/snapshots/tests__highlights_code_inside_macros.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:45:01.043047100+00:00" -creator: insta@0.4.0 +created: "2019-02-01T07:46:59.130146403+00:00" +creator: insta@0.5.3 expression: "&highlights" -source: "crates\\ra_ide_api\\src\\syntax_highlighting.rs" +source: crates/ra_ide_api/src/syntax_highlighting.rs --- [ HighlightedRange { @@ -14,59 +14,31 @@ source: "crates\\ra_ide_api\\src\\syntax_highlighting.rs" tag: "function" }, HighlightedRange { - range: [41; 46), + range: [41; 45), tag: "macro" }, HighlightedRange { - range: [49; 52), + range: [48; 51), tag: "keyword" }, HighlightedRange { - range: [57; 59), + range: [56; 58), tag: "literal" }, HighlightedRange { - range: [82; 86), - tag: "macro" - }, - HighlightedRange { - range: [89; 92), + range: [48; 51), tag: "keyword" }, HighlightedRange { - range: [97; 99), - tag: "literal" - }, - HighlightedRange { - range: [49; 52), - tag: "keyword" - }, - HighlightedRange { - range: [53; 54), + range: [52; 53), tag: "function" }, HighlightedRange { - range: [57; 59), + range: [56; 58), tag: "literal" }, HighlightedRange { - range: [61; 62), - tag: "text" - }, - HighlightedRange { - range: [89; 92), - tag: "keyword" - }, - HighlightedRange { - range: [93; 94), - tag: "function" - }, - HighlightedRange { - range: [97; 99), - tag: "literal" - }, - HighlightedRange { - range: [101; 102), + range: [60; 61), tag: "text" } ] diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs index 26bde495b3f..6c4391e1e81 100644 --- a/crates/ra_ide_api/src/syntax_highlighting.rs +++ b/crates/ra_ide_api/src/syntax_highlighting.rs @@ -42,7 +42,6 @@ fn highlights_code_inside_macros() { let (analysis, file_id) = single_file( " fn main() { - ctry!({ let x = 92; x}); vec![{ let x = 92; x}]; } ",