mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Introduce postfix item types
This commit is contained in:
parent
41d8369d1c
commit
eda4046a05
5 changed files with 50 additions and 33 deletions
|
@ -12,9 +12,11 @@ use syntax::{
|
|||
use text_edit::TextEdit;
|
||||
|
||||
use crate::{
|
||||
completions::postfix::format_like::add_format_like_completions, context::CompletionContext,
|
||||
item::Builder, patterns::ImmediateLocation, CompletionItem, CompletionItemKind,
|
||||
CompletionRelevance, Completions, SnippetScope,
|
||||
completions::postfix::format_like::add_format_like_completions,
|
||||
context::CompletionContext,
|
||||
item::{Builder, CompletionRelevancePostfixMatch},
|
||||
patterns::ImmediateLocation,
|
||||
CompletionItem, CompletionItemKind, CompletionRelevance, Completions, SnippetScope,
|
||||
};
|
||||
|
||||
pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
|
||||
|
@ -240,11 +242,12 @@ fn build_postfix_snippet_builder<'ctx>(
|
|||
let mut item =
|
||||
CompletionItem::new(CompletionItemKind::Snippet, ctx.source_range(), label);
|
||||
item.detail(detail).snippet_edit(cap, edit);
|
||||
let relevance = if ctx.original_token.text() == label {
|
||||
CompletionRelevance { exact_postfix_snippet_match: true, ..Default::default() }
|
||||
let postfix_match = if ctx.original_token.text() == label {
|
||||
Some(CompletionRelevancePostfixMatch::Exact)
|
||||
} else {
|
||||
CompletionRelevance { is_postfix: true, ..Default::default() }
|
||||
Some(CompletionRelevancePostfixMatch::NonExact)
|
||||
};
|
||||
let relevance = CompletionRelevance { postfix_match, ..Default::default() };
|
||||
item.set_relevance(relevance);
|
||||
item
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue