aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/completion/patterns.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-08-25 16:20:29 +0100
committerAleksey Kladov <[email protected]>2020-08-25 16:22:23 +0100
commit18b667cfcb31b2c5e421d12a34b34e83165603f4 (patch)
treec9a8da95da29f52b35e7f06171a34ecaeb9b8cfa /crates/ide/src/completion/patterns.rs
parent6b8bc132dc6dee538964fffa0720480beb5b25dd (diff)
Complete `pub` in fields
Diffstat (limited to 'crates/ide/src/completion/patterns.rs')
-rw-r--r--crates/ide/src/completion/patterns.rs8
1 files changed, 8 insertions, 0 deletions
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 {
34fn test_has_impl_parent() { 34fn test_has_impl_parent() {
35 check_pattern_is_applicable(r"impl A { f<|> }", has_impl_parent); 35 check_pattern_is_applicable(r"impl A { f<|> }", has_impl_parent);
36} 36}
37pub(crate) fn has_field_list_parent(element: SyntaxElement) -> bool {
38 not_same_range_ancestor(element).filter(|it| it.kind() == RECORD_FIELD_LIST).is_some()
39}
40#[test]
41fn test_has_field_list_parent() {
42 check_pattern_is_applicable(r"struct Foo { f<|> }", has_field_list_parent);
43 check_pattern_is_applicable(r"struct Foo { f<|> pub f: i32}", has_field_list_parent);
44}
37 45
38pub(crate) fn has_block_expr_parent(element: SyntaxElement) -> bool { 46pub(crate) fn has_block_expr_parent(element: SyntaxElement) -> bool {
39 not_same_range_ancestor(element).filter(|it| it.kind() == BLOCK_EXPR).is_some() 47 not_same_range_ancestor(element).filter(|it| it.kind() == BLOCK_EXPR).is_some()