Skip to content

Commit 76fd1b3

Browse files
committed
Remove obsolete is_new_item field on CompletionContext
1 parent 9271941 commit 76fd1b3

File tree

4 files changed

+5
-17
lines changed

4 files changed

+5
-17
lines changed

crates/ide_completion/src/completions/macro_in_item_position.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{CompletionContext, Completions};
55
// Ideally this should be removed and moved into `(un)qualified_path` respectively
66
pub(crate) fn complete_macro_in_item_position(acc: &mut Completions, ctx: &CompletionContext) {
77
// Show only macros in top level.
8-
if !ctx.is_new_item {
8+
if !ctx.expects_item() {
99
return;
1010
}
1111

crates/ide_completion/src/completions/snippet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub(crate) fn complete_expr_snippet(acc: &mut Completions, ctx: &CompletionConte
2929
}
3030

3131
pub(crate) fn complete_item_snippet(acc: &mut Completions, ctx: &CompletionContext) {
32-
if !ctx.is_new_item {
32+
if !ctx.expects_item() {
3333
return;
3434
}
3535
let cap = match ctx.config.snippet_cap {

crates/ide_completion/src/context.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ pub(crate) struct CompletionContext<'a> {
7878
pub(super) can_be_stmt: bool,
7979
/// `true` if we expect an expression at the cursor position.
8080
pub(super) is_expr: bool,
81-
/// Something is typed at the "top" level, in module or impl/trait.
82-
pub(super) is_new_item: bool,
8381
/// If this is a call (method or function) in particular, i.e. the () are already there.
8482
pub(super) is_call: bool,
8583
/// Like `is_call`, but for tuple patterns.
@@ -155,7 +153,6 @@ impl<'a> CompletionContext<'a> {
155153
path_qual: None,
156154
can_be_stmt: false,
157155
is_expr: false,
158-
is_new_item: false,
159156
is_call: false,
160157
is_pattern_call: false,
161158
is_macro_call: false,
@@ -552,16 +549,7 @@ impl<'a> CompletionContext<'a> {
552549
self.name_ref_syntax =
553550
find_node_at_offset(original_file, name_ref.syntax().text_range().start());
554551

555-
let name_range = name_ref.syntax().text_range();
556-
let top_node = name_ref
557-
.syntax()
558-
.ancestors()
559-
.take_while(|it| it.text_range() == name_range)
560-
.last()
561-
.unwrap();
562-
563-
if matches!(top_node.parent().map(|it| it.kind()), Some(SOURCE_FILE) | Some(ITEM_LIST)) {
564-
self.is_new_item = true;
552+
if matches!(self.completion_location, Some(ImmediateLocation::ItemList)) {
565553
return;
566554
}
567555

crates/ide_completion/src/patterns.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ use syntax::{
1313
#[cfg(test)]
1414
use crate::test_utils::{check_pattern_is_applicable, check_pattern_is_not_applicable};
1515

16-
/// Direct parent container of the cursor position
16+
/// Immediate previous node to what we are completing.
1717
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
1818
pub(crate) enum ImmediatePrevSibling {
1919
IfExpr,
2020
TraitDefName,
2121
ImplDefType,
2222
}
2323

24-
/// Direct parent container of the cursor position
24+
/// Direct parent "thing" of what we are currently completing.
2525
#[derive(Clone, Debug, PartialEq, Eq)]
2626
pub(crate) enum ImmediateLocation {
2727
Use,

0 commit comments

Comments
 (0)