Skip to content

Commit f78de3b

Browse files
committed
Ignore proc-macro in completion
1 parent 179d983 commit f78de3b

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

crates/ra_hir/src/code_model.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,17 @@ impl MacroDef {
759759
pub fn name(self, db: &dyn HirDatabase) -> Option<Name> {
760760
self.source(db).value.name().map(|it| it.as_name())
761761
}
762+
763+
/// Indicate it is a proc-macro
764+
pub fn is_proc_macro(&self) -> bool {
765+
match self.id.kind {
766+
hir_expand::MacroDefKind::Declarative => false,
767+
hir_expand::MacroDefKind::BuiltIn(_) => false,
768+
hir_expand::MacroDefKind::BuiltInDerive(_) => false,
769+
hir_expand::MacroDefKind::BuiltInEager(_) => false,
770+
hir_expand::MacroDefKind::CustomDerive(_) => true,
771+
}
772+
}
762773
}
763774

764775
/// Invariant: `inner.as_assoc_item(db).is_some()`

crates/ra_ide/src/completion/presentation.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ impl Completions {
156156
name: Option<String>,
157157
macro_: hir::MacroDef,
158158
) {
159+
// FIXME: Currently proc-macro do not have ast-node,
160+
// such that it does not have source
161+
if macro_.is_proc_macro() {
162+
return;
163+
}
164+
159165
let name = match name {
160166
Some(it) => it,
161167
None => return,

0 commit comments

Comments
 (0)