Simplify CompletionContext by introducing a path CallKind enum
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::{item::Builder, CompletionContext};
|
||||
use crate::{context::CallKind, item::Builder, patterns::ImmediateLocation, CompletionContext};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(super) enum Params {
|
||||
@@ -32,10 +32,12 @@ impl Builder {
|
||||
cov_mark::hit!(no_parens_in_use_item);
|
||||
return false;
|
||||
}
|
||||
if ctx.is_pattern_call {
|
||||
return false;
|
||||
}
|
||||
if ctx.is_call {
|
||||
if matches!(ctx.path_call_kind(), Some(CallKind::Expr) | Some(CallKind::Pat))
|
||||
| matches!(
|
||||
ctx.completion_location,
|
||||
Some(ImmediateLocation::MethodCall { has_parens: true, .. })
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ use ide_db::SymbolKind;
|
||||
use syntax::display::macro_label;
|
||||
|
||||
use crate::{
|
||||
context::CallKind,
|
||||
item::{CompletionItem, CompletionKind, ImportEdit},
|
||||
render::RenderContext,
|
||||
};
|
||||
@@ -68,7 +69,8 @@ impl<'a> MacroRender<'a> {
|
||||
}
|
||||
|
||||
fn needs_bang(&self) -> bool {
|
||||
self.ctx.completion.use_item_syntax.is_none() && !self.ctx.completion.is_macro_call
|
||||
self.ctx.completion.use_item_syntax.is_none()
|
||||
&& !matches!(self.ctx.completion.path_call_kind(), Some(CallKind::Mac))
|
||||
}
|
||||
|
||||
fn label(&self) -> String {
|
||||
|
||||
Reference in New Issue
Block a user