Unnamed repository; edit this file 'description' to name the repository.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! Completion of field list position.

use crate::{
    context::{
        NameContext, NameKind, NameRefContext, NameRefKind, PathCompletionCtx, PathKind, Qualified,
        TypeLocation,
    },
    CompletionContext, Completions,
};

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,
                    qualified: Qualified::No,
                    parent: None,
                    kind: PathKind::Type { location: TypeLocation::TupleField },
                    has_type_args: false,
                    ..
                })),
            ..
        } => {
            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");
            }
        }
        _ => (),
    }
}

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");
        }
    }
}