Remove obsolete is_new_item field on CompletionContext
This commit is contained in:
parent
9271941a95
commit
76fd1b316f
@ -5,7 +5,7 @@ use crate::{CompletionContext, Completions};
|
||||
// Ideally this should be removed and moved into `(un)qualified_path` respectively
|
||||
pub(crate) fn complete_macro_in_item_position(acc: &mut Completions, ctx: &CompletionContext) {
|
||||
// Show only macros in top level.
|
||||
if !ctx.is_new_item {
|
||||
if !ctx.expects_item() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ pub(crate) fn complete_expr_snippet(acc: &mut Completions, ctx: &CompletionConte
|
||||
}
|
||||
|
||||
pub(crate) fn complete_item_snippet(acc: &mut Completions, ctx: &CompletionContext) {
|
||||
if !ctx.is_new_item {
|
||||
if !ctx.expects_item() {
|
||||
return;
|
||||
}
|
||||
let cap = match ctx.config.snippet_cap {
|
||||
|
@ -78,8 +78,6 @@ pub(crate) struct CompletionContext<'a> {
|
||||
pub(super) can_be_stmt: bool,
|
||||
/// `true` if we expect an expression at the cursor position.
|
||||
pub(super) is_expr: bool,
|
||||
/// Something is typed at the "top" level, in module or impl/trait.
|
||||
pub(super) is_new_item: bool,
|
||||
/// If this is a call (method or function) in particular, i.e. the () are already there.
|
||||
pub(super) is_call: bool,
|
||||
/// Like `is_call`, but for tuple patterns.
|
||||
@ -155,7 +153,6 @@ impl<'a> CompletionContext<'a> {
|
||||
path_qual: None,
|
||||
can_be_stmt: false,
|
||||
is_expr: false,
|
||||
is_new_item: false,
|
||||
is_call: false,
|
||||
is_pattern_call: false,
|
||||
is_macro_call: false,
|
||||
@ -552,16 +549,7 @@ impl<'a> CompletionContext<'a> {
|
||||
self.name_ref_syntax =
|
||||
find_node_at_offset(original_file, name_ref.syntax().text_range().start());
|
||||
|
||||
let name_range = name_ref.syntax().text_range();
|
||||
let top_node = name_ref
|
||||
.syntax()
|
||||
.ancestors()
|
||||
.take_while(|it| it.text_range() == name_range)
|
||||
.last()
|
||||
.unwrap();
|
||||
|
||||
if matches!(top_node.parent().map(|it| it.kind()), Some(SOURCE_FILE) | Some(ITEM_LIST)) {
|
||||
self.is_new_item = true;
|
||||
if matches!(self.completion_location, Some(ImmediateLocation::ItemList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ use syntax::{
|
||||
#[cfg(test)]
|
||||
use crate::test_utils::{check_pattern_is_applicable, check_pattern_is_not_applicable};
|
||||
|
||||
/// Direct parent container of the cursor position
|
||||
/// Immediate previous node to what we are completing.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum ImmediatePrevSibling {
|
||||
IfExpr,
|
||||
@ -21,7 +21,7 @@ pub(crate) enum ImmediatePrevSibling {
|
||||
ImplDefType,
|
||||
}
|
||||
|
||||
/// Direct parent container of the cursor position
|
||||
/// Direct parent "thing" of what we are currently completing.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum ImmediateLocation {
|
||||
Use,
|
||||
|
Loading…
x
Reference in New Issue
Block a user