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 ++++++++++++++---------------- crates/ide_db/src/call_info.rs | 3 +-- 2 files changed, 15 insertions(+), 18 deletions(-) (limited to 'crates') 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(); diff --git a/crates/ide_db/src/call_info.rs b/crates/ide_db/src/call_info.rs index bad277a95..933bcad55 100644 --- a/crates/ide_db/src/call_info.rs +++ b/crates/ide_db/src/call_info.rs @@ -223,9 +223,8 @@ impl FnCallNode { ast::Expr::PathExpr(path_expr) => path_expr.path()?.segment()?.name_ref()?, _ => return None, }), - FnCallNode::MethodCallExpr(call_expr) => { - call_expr.syntax().children().filter_map(ast::NameRef::cast).next() + call_expr.syntax().children().find_map(ast::NameRef::cast) } } } -- cgit v1.2.3