Skip to content

Commit 26fef97

Browse files
committed
Simplify
1 parent 822d9b5 commit 26fef97

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

crates/ide-completion/src/context.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ impl<'a> CompletionContext<'a> {
326326
matches!(self.completion_location, Some(ImmediateLocation::ItemList))
327327
}
328328

329+
// FIXME: This shouldn't exist
329330
pub(crate) fn expects_generic_arg(&self) -> bool {
330331
matches!(self.completion_location, Some(ImmediateLocation::GenericArgList(_)))
331332
}
@@ -395,10 +396,6 @@ impl<'a> CompletionContext<'a> {
395396
matches!(self.path_context(), Some(PathCompletionCtx { kind: PathKind::Type, .. }))
396397
}
397398

398-
pub(crate) fn path_is_call(&self) -> bool {
399-
self.path_context().map_or(false, |it| it.has_call_parens)
400-
}
401-
402399
pub(crate) fn is_non_trivial_path(&self) -> bool {
403400
matches!(
404401
self.path_context(),
@@ -417,10 +414,6 @@ impl<'a> CompletionContext<'a> {
417414
self.path_context().map(|it| it.kind)
418415
}
419416

420-
pub(crate) fn is_immediately_after_macro_bang(&self) -> bool {
421-
self.token.kind() == BANG && self.token.parent().map_or(false, |it| it.kind() == MACRO_CALL)
422-
}
423-
424417
/// Checks if an item is visible and not `doc(hidden)` at the completion site.
425418
pub(crate) fn is_visible<I>(&self, item: &I) -> Visible
426419
where

crates/ide-completion/src/render.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@ impl<'a> RenderContext<'a> {
6565
}
6666
}
6767

68+
fn is_immediately_after_macro_bang(&self) -> bool {
69+
self.completion.token.kind() == SyntaxKind::BANG
70+
&& self
71+
.completion
72+
.token
73+
.parent()
74+
.map_or(false, |it| it.kind() == SyntaxKind::MACRO_CALL)
75+
}
76+
77+
pub(crate) fn path_is_call(&self) -> bool {
78+
self.completion.path_context().map_or(false, |it| it.has_call_parens)
79+
}
80+
6881
fn is_deprecated(&self, def: impl HasAttrs) -> bool {
6982
let attrs = def.attrs(self.db());
7083
attrs.by_key("deprecated").exists() || attrs.by_key("rustc_deprecated").exists()

crates/ide-completion/src/render/macro_.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn render(
2020
name: hir::Name,
2121
macro_: hir::Macro,
2222
) -> Builder {
23-
let source_range = if completion.is_immediately_after_macro_bang() {
23+
let source_range = if ctx.is_immediately_after_macro_bang() {
2424
cov_mark::hit!(completes_macro_call_if_cursor_at_bang_token);
2525
completion.token.parent().map_or_else(|| ctx.source_range(), |it| it.text_range())
2626
} else {
@@ -52,7 +52,7 @@ fn render(
5252

5353
let name = &*name;
5454
match ctx.snippet_cap() {
55-
Some(cap) if needs_bang && !completion.path_is_call() => {
55+
Some(cap) if needs_bang && !ctx.path_is_call() => {
5656
let snippet = format!("{}!{}$0{}", name, bra, ket);
5757
let lookup = banged_name(name);
5858
item.insert_snippet(cap, snippet).lookup_by(lookup);

0 commit comments

Comments
 (0)