mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-29 06:23:25 +00:00
add test for postfix completion relevance
Follow up to #11857, add a test and cov-marks
This commit is contained in:
parent
40cba42e47
commit
a8f460209d
2 changed files with 33 additions and 1 deletions
|
@ -243,8 +243,10 @@ fn build_postfix_snippet_builder<'ctx>(
|
|||
CompletionItem::new(CompletionItemKind::Snippet, ctx.source_range(), label);
|
||||
item.detail(detail).snippet_edit(cap, edit);
|
||||
let postfix_match = if ctx.original_token.text() == label {
|
||||
cov_mark::hit!(postfix_exact_match_is_high_priority);
|
||||
Some(CompletionRelevancePostfixMatch::Exact)
|
||||
} else {
|
||||
cov_mark::hit!(postfix_inexact_match_is_low_priority);
|
||||
Some(CompletionRelevancePostfixMatch::NonExact)
|
||||
};
|
||||
let relevance = CompletionRelevance { postfix_match, ..Default::default() };
|
||||
|
|
|
@ -1550,7 +1550,8 @@ fn foo() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn postfix_completion_relevance() {
|
||||
fn postfix_exact_match_is_high_priority() {
|
||||
cov_mark::check!(postfix_exact_match_is_high_priority);
|
||||
check_relevance_for_kinds(
|
||||
r#"
|
||||
mod ops {
|
||||
|
@ -1585,4 +1586,33 @@ fn main() {
|
|||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn postfix_inexact_match_is_low_priority() {
|
||||
cov_mark::check!(postfix_inexact_match_is_low_priority);
|
||||
check_relevance_for_kinds(
|
||||
r#"
|
||||
struct S;
|
||||
impl S {
|
||||
fn f(&self) {}
|
||||
}
|
||||
fn main() {
|
||||
S.$0
|
||||
}
|
||||
"#,
|
||||
&[CompletionItemKind::Snippet, CompletionItemKind::Method],
|
||||
expect![[r#"
|
||||
me f() []
|
||||
sn ref []
|
||||
sn refm []
|
||||
sn match []
|
||||
sn box []
|
||||
sn dbg []
|
||||
sn dbgr []
|
||||
sn call []
|
||||
sn let []
|
||||
sn letm []
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue