From aa29364f831c4633613ba7e28cae147e69107d66 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 7 Jun 2021 19:06:03 +0200 Subject: Reorder CompletionContext fields --- crates/ide_completion/src/context.rs | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'crates/ide_completion/src/context.rs') diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs index 20e033d31..58762a3cd 100644 --- a/crates/ide_completion/src/context.rs +++ b/crates/ide_completion/src/context.rs @@ -67,14 +67,13 @@ pub(crate) struct CompletionContext<'a> { pub(super) krate: Option, pub(super) expected_name: Option, pub(super) expected_type: Option, - pub(super) name_ref_syntax: Option, - - pub(super) use_item_syntax: Option, /// The parent function of the cursor position if it exists. pub(super) function_def: Option, /// The parent impl of the cursor position if it exists. pub(super) impl_def: Option, + pub(super) name_ref_syntax: Option, + pub(super) use_item_syntax: Option, // potentially set if we are completing a lifetime pub(super) lifetime_syntax: Option, @@ -89,13 +88,12 @@ pub(crate) struct CompletionContext<'a> { pub(super) completion_location: Option, pub(super) prev_sibling: Option, pub(super) attribute_under_caret: Option, + pub(super) previous_token: Option, pub(super) path_context: Option, - /// FIXME: `ActiveParameter` is string-based, which is very very wrong pub(super) active_parameter: Option, pub(super) locals: Vec<(String, Local)>, - pub(super) previous_token: Option, pub(super) in_loop_body: bool, pub(super) incomplete_let: bool, @@ -143,28 +141,28 @@ impl<'a> CompletionContext<'a> { original_token, token, krate, - lifetime_allowed: false, expected_name: None, expected_type: None, + function_def: None, + impl_def: None, name_ref_syntax: None, + use_item_syntax: None, lifetime_syntax: None, lifetime_param_syntax: None, - function_def: None, - use_item_syntax: None, - impl_def: None, - active_parameter: ActiveParameter::at(db, position), + lifetime_allowed: false, is_label_ref: false, - is_param: false, is_pat_or_const: None, - path_context: None, - previous_token: None, - in_loop_body: false, + is_param: false, completion_location: None, prev_sibling: None, - no_completion_required: false, - incomplete_let: false, attribute_under_caret: None, + previous_token: None, + path_context: None, + active_parameter: ActiveParameter::at(db, position), locals, + in_loop_body: false, + incomplete_let: false, + no_completion_required: false, }; let mut original_file = original_file.syntax().clone(); -- cgit v1.2.3 From b29e8ed994c573273a8182efd9b74ec8c664a848 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 7 Jun 2021 19:35:24 +0200 Subject: Remove unnecessary completion::macro_in_item_position --- crates/ide_completion/src/context.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'crates/ide_completion/src/context.rs') diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs index 58762a3cd..7e4b14926 100644 --- a/crates/ide_completion/src/context.rs +++ b/crates/ide_completion/src/context.rs @@ -561,10 +561,6 @@ impl<'a> CompletionContext<'a> { self.name_ref_syntax = find_node_at_offset(original_file, name_ref.syntax().text_range().start()); - if matches!(self.completion_location, Some(ImmediateLocation::ItemList)) { - return; - } - self.use_item_syntax = self.sema.token_ancestors_with_macros(self.token.clone()).find_map(ast::Use::cast); @@ -595,7 +591,7 @@ impl<'a> CompletionContext<'a> { path_ctx.call_kind = match_ast! { match p { ast::PathExpr(it) => it.syntax().parent().and_then(ast::CallExpr::cast).map(|_| CallKind::Expr), - ast::MacroCall(_it) => Some(CallKind::Mac), + ast::MacroCall(it) => it.excl_token().and(Some(CallKind::Mac)), ast::TupleStructPat(_it) => Some(CallKind::Pat), _ => None } -- cgit v1.2.3