From 18b667cfcb31b2c5e421d12a34b34e83165603f4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 25 Aug 2020 17:20:29 +0200 Subject: Complete `pub` in fields --- crates/ide/src/completion/patterns.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'crates/ide/src/completion/patterns.rs') diff --git a/crates/ide/src/completion/patterns.rs b/crates/ide/src/completion/patterns.rs index ffc97c076..c6ae589db 100644 --- a/crates/ide/src/completion/patterns.rs +++ b/crates/ide/src/completion/patterns.rs @@ -34,6 +34,14 @@ pub(crate) fn has_impl_parent(element: SyntaxElement) -> bool { fn test_has_impl_parent() { check_pattern_is_applicable(r"impl A { f<|> }", has_impl_parent); } +pub(crate) fn has_field_list_parent(element: SyntaxElement) -> bool { + not_same_range_ancestor(element).filter(|it| it.kind() == RECORD_FIELD_LIST).is_some() +} +#[test] +fn test_has_field_list_parent() { + check_pattern_is_applicable(r"struct Foo { f<|> }", has_field_list_parent); + check_pattern_is_applicable(r"struct Foo { f<|> pub f: i32}", has_field_list_parent); +} pub(crate) fn has_block_expr_parent(element: SyntaxElement) -> bool { not_same_range_ancestor(element).filter(|it| it.kind() == BLOCK_EXPR).is_some() -- cgit v1.2.3