Ignore proc-macro in completion

This commit is contained in:
Edwin Cheng 2020-04-18 19:26:35 +08:00
parent 179d983535
commit f78de3bb95
2 changed files with 17 additions and 0 deletions

View file

@ -759,6 +759,17 @@ impl MacroDef {
pub fn name(self, db: &dyn HirDatabase) -> Option<Name> {
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()`

View file

@ -156,6 +156,12 @@ impl Completions {
name: Option<String>,
macro_: hir::MacroDef,
) {
// FIXME: Currently proc-macro do not have ast-node,
// such that it does not have source
if macro_.is_proc_macro() {
return;
}
let name = match name {
Some(it) => it,
None => return,