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 + 2 files changed, 3 insertions(+), 24 deletions(-) (limited to 'crates/ra_hir/src') 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( " -- cgit v1.2.3