From f78de3bb95acb996102a74b5b12d33054ba6d4c4 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sat, 18 Apr 2020 19:26:35 +0800 Subject: Ignore proc-macro in completion --- crates/ra_hir/src/code_model.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 3801fce23..6e0d89466 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -759,6 +759,17 @@ impl MacroDef { pub fn name(self, db: &dyn HirDatabase) -> Option { self.source(db).value.name().map(|it| it.as_name()) } + + /// Indicate it is a proc-macro + pub fn is_proc_macro(&self) -> bool { + match self.id.kind { + hir_expand::MacroDefKind::Declarative => false, + hir_expand::MacroDefKind::BuiltIn(_) => false, + hir_expand::MacroDefKind::BuiltInDerive(_) => false, + hir_expand::MacroDefKind::BuiltInEager(_) => false, + hir_expand::MacroDefKind::CustomDerive(_) => true, + } + } } /// Invariant: `inner.as_assoc_item(db).is_some()` -- cgit v1.2.3