internal: Split flyimport into its 3 applicable contexts

This commit is contained in:
Lukas Wirth 2022-06-18 00:47:28 +02:00
parent 00fdb4a3d8
commit 173bb10a76
6 changed files with 171 additions and 132 deletions

View file

@ -9,7 +9,7 @@ use syntax::SmolStr;
use crate::{
context::{
CompletionContext, DotAccess, DotAccessKind, IdentContext, NameRefContext, NameRefKind,
PathCompletionCtx, PathKind,
PathCompletionCtx, PathKind, Qualified,
},
item::{Builder, CompletionItem, CompletionItemKind, CompletionRelevance},
render::{compute_exact_name_match, compute_ref_match, compute_type_match, RenderContext},
@ -80,7 +80,17 @@ fn render(
// FIXME For now we don't properly calculate the edits for ref match
// completions on methods or qualified paths, so we've disabled them.
// See #8058.
if matches!(func_kind, FuncKind::Function) && ctx.completion.path_qual().is_none() {
let qualified_path = matches!(
ctx.completion.ident_ctx,
IdentContext::NameRef(NameRefContext {
kind: Some(NameRefKind::Path(PathCompletionCtx {
qualified: Qualified::With { .. },
..
})),
..
})
);
if matches!(func_kind, FuncKind::Function) && !qualified_path {
item.ref_match(ref_match);
}
}