From 33be5762e579a9e03288ba27821951ca7db3a68e Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 7 Jun 2021 19:32:28 +0200 Subject: Attempt to track attr macros during highlighting --- crates/hir/src/semantics.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'crates/hir/src') diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index 920e18208..2d08a7704 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -123,6 +123,10 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { self.imp.expand_attr_macro(item) } + pub fn is_attr_macro_call(&self, item: &ast::Item) -> bool { + self.imp.is_attr_macro_call(item) + } + pub fn speculative_expand( &self, actual_macro_call: &ast::MacroCall, @@ -348,6 +352,12 @@ impl<'db> SemanticsImpl<'db> { Some(node) } + fn is_attr_macro_call(&self, item: &ast::Item) -> bool { + let sa = self.analyze(item.syntax()); + let src = InFile::new(sa.file_id, item.clone()); + self.with_ctx(|ctx| ctx.item_to_macro_call(src).is_some()) + } + fn speculative_expand( &self, actual_macro_call: &ast::MacroCall, -- cgit v1.2.3