// 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;
}
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.
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,
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;
}
#[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,
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,