Save variant names in EnumData to reduce needless queries
We already have their names when anyway, and when in all (current) situations where we're interested in an Enum's variants, we want their names.
This commit is contained in:
@@ -23,17 +23,12 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) -> C
|
||||
}
|
||||
hir::Def::Enum(e) => {
|
||||
e.variants(ctx.db)?
|
||||
.unwrap_or(vec![])
|
||||
.into_iter()
|
||||
.for_each(|variant| {
|
||||
let variant_name = variant.name(ctx.db);
|
||||
|
||||
if let Ok(Some(name)) = variant_name {
|
||||
CompletionItem::new(CompletionKind::Reference, name.to_string())
|
||||
.kind(CompletionItemKind::EnumVariant)
|
||||
.add_to(acc)
|
||||
}
|
||||
})
|
||||
.for_each(|(variant_name, _variant)| {
|
||||
CompletionItem::new(CompletionKind::Reference, variant_name.to_string())
|
||||
.kind(CompletionItemKind::EnumVariant)
|
||||
.add_to(acc)
|
||||
});
|
||||
}
|
||||
_ => return Ok(()),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user