mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Only run completion functions if their corresponding context is active
This commit is contained in:
parent
d97a8ee865
commit
00fdb4a3d8
29 changed files with 562 additions and 397 deletions
|
@ -4,7 +4,9 @@ use hir::{db::HirDatabase, Documentation, HasAttrs, StructKind};
|
|||
use ide_db::SymbolKind;
|
||||
|
||||
use crate::{
|
||||
context::{CompletionContext, PathCompletionCtx, PathKind},
|
||||
context::{
|
||||
CompletionContext, IdentContext, NameRefContext, NameRefKind, PathCompletionCtx, PathKind,
|
||||
},
|
||||
item::{Builder, CompletionItem},
|
||||
render::{
|
||||
compute_ref_match, compute_type_match,
|
||||
|
@ -51,12 +53,19 @@ fn render(
|
|||
) -> Option<Builder> {
|
||||
let db = completion.db;
|
||||
let mut kind = thing.kind(db);
|
||||
let should_add_parens = match completion.path_context() {
|
||||
Some(PathCompletionCtx { has_call_parens: true, .. }) => false,
|
||||
Some(PathCompletionCtx { kind: PathKind::Use | PathKind::Type { .. }, .. }) => {
|
||||
cov_mark::hit!(no_parens_in_use_item);
|
||||
false
|
||||
}
|
||||
let should_add_parens = match &completion.ident_ctx {
|
||||
IdentContext::NameRef(NameRefContext {
|
||||
kind: Some(NameRefKind::Path(PathCompletionCtx { has_call_parens: true, .. })),
|
||||
..
|
||||
}) => false,
|
||||
IdentContext::NameRef(NameRefContext {
|
||||
kind:
|
||||
Some(NameRefKind::Path(PathCompletionCtx {
|
||||
kind: PathKind::Use | PathKind::Type { .. },
|
||||
..
|
||||
})),
|
||||
..
|
||||
}) => false,
|
||||
_ => true,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue