From 0d060b073ce965511e3c794c4b6e70f69d14d2ff Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 11 Feb 2019 22:24:39 +0300 Subject: remove hard-coded query-group macro --- crates/ra_hir/src/macros.rs | 26 ++------------------ crates/ra_hir/src/nameres/tests.rs | 1 + .../tests__highlight_query_group_macro.snap | 28 ---------------------- crates/ra_ide_api/src/syntax_highlighting.rs | 15 ------------ crates/ra_ide_api/tests/test/main.rs | 1 + 5 files changed, 4 insertions(+), 67 deletions(-) delete mode 100644 crates/ra_ide_api/src/snapshots/tests__highlight_query_group_macro.snap diff --git a/crates/ra_hir/src/macros.rs b/crates/ra_hir/src/macros.rs index a8070637e..dd477e9f9 100644 --- a/crates/ra_hir/src/macros.rs +++ b/crates/ra_hir/src/macros.rs @@ -11,7 +11,7 @@ use std::sync::Arc; use ra_syntax::{ TextRange, TextUnit, SourceFile, AstNode, SyntaxNode, TreeArc, SyntaxNodePtr, - ast::{self, NameOwner}, + ast, }; use crate::{MacroCallId, PersistentHirDatabase}; @@ -20,7 +20,6 @@ use crate::{MacroCallId, PersistentHirDatabase}; #[derive(Debug, Clone, PartialEq, Eq)] pub enum MacroDef { Vec, - QueryGroup, } impl MacroDef { @@ -39,8 +38,6 @@ impl MacroDef { let name_ref = path.segment()?.name_ref()?; if name_ref.text() == "vec" { MacroDef::Vec - } else if name_ref.text() == "query_group" { - MacroDef::QueryGroup } else { return None; } @@ -56,7 +53,6 @@ impl MacroDef { fn expand(self, input: MacroInput) -> Option { match self { MacroDef::Vec => self.expand_vec(input), - MacroDef::QueryGroup => self.expand_query_group(input), } } fn expand_vec(self, input: MacroInput) -> Option { @@ -69,24 +65,6 @@ impl MacroDef { let res = MacroExpansion { text, ranges_map, ptr }; Some(res) } - fn expand_query_group(self, input: MacroInput) -> Option { - let anchor = "trait "; - let pos = input.text.find(anchor)? + anchor.len(); - let trait_name = - input.text[pos..].chars().take_while(|c| c.is_alphabetic()).collect::(); - if trait_name.is_empty() { - return None; - } - let src_range = TextRange::offset_len((pos as u32).into(), TextUnit::of_str(&trait_name)); - let text = format!(r"trait {} {{ }}", trait_name); - let file = SourceFile::parse(&text); - let trait_def = file.syntax().descendants().find_map(ast::TraitDef::cast)?; - let name = trait_def.name()?; - let ptr = SyntaxNodePtr::new(trait_def.syntax()); - let ranges_map = vec![(src_range, name.syntax().range())]; - let res = MacroExpansion { text, ranges_map, ptr }; - Some(res) - } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -109,7 +87,7 @@ pub struct MacroExpansion { } impl MacroExpansion { - // FIXME: does not really make sense, macro expansion is not neccessary a + // FIXME: does not really make sense, macro expansion is not necessary a // whole file. See `MacroExpansion::ptr` as well. pub(crate) fn file(&self) -> TreeArc { SourceFile::parse(&self.text) diff --git a/crates/ra_hir/src/nameres/tests.rs b/crates/ra_hir/src/nameres/tests.rs index f1a1f5b76..6dbe759d1 100644 --- a/crates/ra_hir/src/nameres/tests.rs +++ b/crates/ra_hir/src/nameres/tests.rs @@ -326,6 +326,7 @@ fn name_res_works_for_broken_modules() { } #[test] +#[ignore] fn item_map_contains_items_from_expansions() { let (item_map, module_id) = item_map( " 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 deleted file mode 100644 index 0b802ac3d..000000000 --- a/crates/ra_ide_api/src/snapshots/tests__highlight_query_group_macro.snap +++ /dev/null @@ -1,28 +0,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 ---- -[ - HighlightedRange { - range: [20; 32), - tag: "macro" - }, - HighlightedRange { - range: [13; 18), - tag: "text" - }, - HighlightedRange { - range: [51; 54), - tag: "keyword" - }, - HighlightedRange { - range: [55; 60), - tag: "keyword" - }, - HighlightedRange { - range: [61; 72), - tag: "function" - } -] diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs index a435fe56e..345b6653d 100644 --- a/crates/ra_ide_api/src/syntax_highlighting.rs +++ b/crates/ra_ide_api/src/syntax_highlighting.rs @@ -41,19 +41,4 @@ mod tests { let highlights = analysis.highlight(file_id).unwrap(); assert_debug_snapshot_matches!("highlights_code_inside_macros", &highlights); } - - // FIXME: this test is not really necessary: artifact of the inital hacky - // macros implementation. - #[test] - fn highlight_query_group_macro() { - let (analysis, file_id) = single_file( - " - salsa::query_group! { - pub trait HirDatabase: SyntaxDatabase {} - } - ", - ); - let highlights = analysis.highlight(file_id).unwrap(); - assert_debug_snapshot_matches!("highlight_query_group_macro", &highlights); - } } diff --git a/crates/ra_ide_api/tests/test/main.rs b/crates/ra_ide_api/tests/test/main.rs index c2cb38f7e..7d1695cfd 100644 --- a/crates/ra_ide_api/tests/test/main.rs +++ b/crates/ra_ide_api/tests/test/main.rs @@ -91,6 +91,7 @@ fn test_find_all_refs_for_fn_param() { } #[test] +#[ignore] fn world_symbols_include_stuff_from_macros() { let (analysis, _) = single_file( " -- cgit v1.2.3