add tests for the completion of the callable field

This commit is contained in:
dfireBird 2023-11-12 16:44:57 +05:30
parent 7cf3ab4bd2
commit 5bcafd7dc0
No known key found for this signature in database
GPG Key ID: 26D522CA5FC2B93D
2 changed files with 44 additions and 7 deletions

View File

@ -1206,4 +1206,17 @@ impl<B: Bar, F: core::ops::Deref<Target = B>> Foo<F> {
"#]],
);
}
#[test]
fn test_struct_function_field_completion() {
check(
r#"
struct S { field: fn() }
fn foo() { S { field: || {} }.fi$0() }
"#,
expect![[r#"
fd field fn()
"#]],
);
}
}

View File

@ -1634,7 +1634,7 @@ fn main() {
fn struct_field_method_ref() {
check_kinds(
r#"
struct Foo { bar: u32 }
struct Foo { bar: u32, qux: fn() }
impl Foo { fn baz(&self) -> u32 { 0 } }
fn foo(f: Foo) { let _: &u32 = f.b$0 }
@ -1644,24 +1644,48 @@ fn foo(f: Foo) { let _: &u32 = f.b$0 }
[
CompletionItem {
label: "baz()",
source_range: 98..99,
delete: 98..99,
source_range: 109..110,
delete: 109..110,
insert: "baz()$0",
kind: Method,
lookup: "baz",
detail: "fn(&self) -> u32",
ref_match: "&@96",
ref_match: "&@107",
},
CompletionItem {
label: "bar",
source_range: 98..99,
delete: 98..99,
source_range: 109..110,
delete: 109..110,
insert: "bar",
kind: SymbolKind(
Field,
),
detail: "u32",
ref_match: "&@96",
ref_match: "&@107",
},
CompletionItem {
label: "qux",
source_range: 109..110,
text_edit: TextEdit {
indels: [
Indel {
insert: "(",
delete: 107..107,
},
Indel {
insert: ")",
delete: 108..108,
},
Indel {
insert: "qux()",
delete: 109..110,
},
],
},
kind: SymbolKind(
Field,
),
detail: "fn()",
},
]
"#]],