diff options
author | Marcus Klaas de Vries <[email protected]> | 2019-01-10 01:07:42 +0000 |
---|---|---|
committer | Marcus Klaas de Vries <[email protected]> | 2019-01-10 13:43:01 +0000 |
commit | e78286c8e88d31045d354320a1d29bbd75405027 (patch) | |
tree | ed4c6f986b6ede2bbafa19a66dd81f5be2d0371c /crates/ra_ide_api/src | |
parent | 978de5cf8bfd2ff82696fc8d5369b41e147431c3 (diff) |
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.
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_path.rs | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index 6a55670d1..9bfec88d0 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs | |||
@@ -23,17 +23,12 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) -> C | |||
23 | } | 23 | } |
24 | hir::Def::Enum(e) => { | 24 | hir::Def::Enum(e) => { |
25 | e.variants(ctx.db)? | 25 | e.variants(ctx.db)? |
26 | .unwrap_or(vec![]) | ||
27 | .into_iter() | 26 | .into_iter() |
28 | .for_each(|variant| { | 27 | .for_each(|(variant_name, _variant)| { |
29 | let variant_name = variant.name(ctx.db); | 28 | CompletionItem::new(CompletionKind::Reference, variant_name.to_string()) |
30 | 29 | .kind(CompletionItemKind::EnumVariant) | |
31 | if let Ok(Some(name)) = variant_name { | 30 | .add_to(acc) |
32 | CompletionItem::new(CompletionKind::Reference, name.to_string()) | 31 | }); |
33 | .kind(CompletionItemKind::EnumVariant) | ||
34 | .add_to(acc) | ||
35 | } | ||
36 | }) | ||
37 | } | 32 | } |
38 | _ => return Ok(()), | 33 | _ => return Ok(()), |
39 | }; | 34 | }; |