2022-06-03 15:41:51 +02:00
|
|
|
//! Completion of field list position.
|
|
|
|
|
|
|
|
use crate::{
|
2022-06-17 10:45:19 +02:00
|
|
|
context::{
|
2022-06-17 23:36:39 +02:00
|
|
|
NameContext, NameKind, NameRefContext, NameRefKind, PathCompletionCtx, PathKind, Qualified,
|
|
|
|
TypeLocation,
|
2022-06-17 10:45:19 +02:00
|
|
|
},
|
2022-06-03 16:33:37 +02:00
|
|
|
CompletionContext, Completions,
|
2022-06-03 15:41:51 +02:00
|
|
|
};
|
|
|
|
|
2022-06-17 23:36:39 +02:00
|
|
|
pub(crate) fn complete_field_list_tuple_variant(
|
|
|
|
acc: &mut Completions,
|
|
|
|
ctx: &CompletionContext,
|
|
|
|
name_ref_ctx: &NameRefContext,
|
|
|
|
) {
|
|
|
|
match name_ref_ctx {
|
|
|
|
NameRefContext {
|
2022-06-17 10:45:19 +02:00
|
|
|
kind:
|
|
|
|
Some(NameRefKind::Path(PathCompletionCtx {
|
2022-06-03 15:41:51 +02:00
|
|
|
has_macro_bang: false,
|
2022-06-17 16:36:22 +02:00
|
|
|
qualified: Qualified::No,
|
2022-06-03 15:41:51 +02:00
|
|
|
parent: None,
|
2022-06-17 14:18:03 +02:00
|
|
|
kind: PathKind::Type { location: TypeLocation::TupleField },
|
2022-06-03 15:41:51 +02:00
|
|
|
has_type_args: false,
|
|
|
|
..
|
2022-06-17 10:45:19 +02:00
|
|
|
})),
|
2022-06-03 15:41:51 +02:00
|
|
|
..
|
2022-06-17 23:36:39 +02:00
|
|
|
} => {
|
2022-06-03 15:41:51 +02:00
|
|
|
if ctx.qualifier_ctx.vis_node.is_none() {
|
2022-06-03 16:33:37 +02:00
|
|
|
let mut add_keyword = |kw, snippet| acc.add_keyword_snippet(ctx, kw, snippet);
|
2022-06-03 15:41:51 +02:00
|
|
|
add_keyword("pub(crate)", "pub(crate)");
|
|
|
|
add_keyword("pub(super)", "pub(super)");
|
|
|
|
add_keyword("pub", "pub");
|
|
|
|
}
|
|
|
|
}
|
2022-06-17 23:36:39 +02:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
2022-06-03 15:41:51 +02:00
|
|
|
}
|
|
|
|
}
|