Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/completions/field.rs')
| -rw-r--r-- | crates/ide-completion/src/completions/field.rs | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/crates/ide-completion/src/completions/field.rs b/crates/ide-completion/src/completions/field.rs index a9f598fffd..93263f61cf 100644 --- a/crates/ide-completion/src/completions/field.rs +++ b/crates/ide-completion/src/completions/field.rs @@ -2,16 +2,19 @@ use crate::{ context::{ - IdentContext, NameContext, NameKind, NameRefContext, NameRefKind, PathCompletionCtx, - PathKind, Qualified, TypeLocation, + NameContext, NameKind, NameRefContext, NameRefKind, PathCompletionCtx, PathKind, Qualified, + TypeLocation, }, CompletionContext, Completions, }; -pub(crate) fn complete_field_list(acc: &mut Completions, ctx: &CompletionContext) { - match &ctx.ident_ctx { - IdentContext::Name(NameContext { kind: NameKind::RecordField, .. }) - | IdentContext::NameRef(NameRefContext { +pub(crate) fn complete_field_list_tuple_variant( + acc: &mut Completions, + ctx: &CompletionContext, + name_ref_ctx: &NameRefContext, +) { + match name_ref_ctx { + NameRefContext { kind: Some(NameRefKind::Path(PathCompletionCtx { has_macro_bang: false, @@ -22,7 +25,7 @@ pub(crate) fn complete_field_list(acc: &mut Completions, ctx: &CompletionContext .. })), .. - }) => { + } => { if ctx.qualifier_ctx.vis_node.is_none() { let mut add_keyword = |kw, snippet| acc.add_keyword_snippet(ctx, kw, snippet); add_keyword("pub(crate)", "pub(crate)"); @@ -30,6 +33,21 @@ pub(crate) fn complete_field_list(acc: &mut Completions, ctx: &CompletionContext add_keyword("pub", "pub"); } } - _ => return, + _ => (), + } +} + +pub(crate) fn complete_field_list_record_variant( + acc: &mut Completions, + ctx: &CompletionContext, + name_ctx: &NameContext, +) { + if let NameContext { kind: NameKind::RecordField, .. } = name_ctx { + if ctx.qualifier_ctx.vis_node.is_none() { + let mut add_keyword = |kw, snippet| acc.add_keyword_snippet(ctx, kw, snippet); + add_keyword("pub(crate)", "pub(crate)"); + add_keyword("pub(super)", "pub(super)"); + add_keyword("pub", "pub"); + } } } |