Skip to content

Commit aa29364

Browse files
committed
Reorder CompletionContext fields
1 parent 8b6c3ea commit aa29364

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

crates/ide_completion/src/context.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,13 @@ pub(crate) struct CompletionContext<'a> {
6767
pub(super) krate: Option<hir::Crate>,
6868
pub(super) expected_name: Option<NameOrNameRef>,
6969
pub(super) expected_type: Option<Type>,
70-
pub(super) name_ref_syntax: Option<ast::NameRef>,
71-
72-
pub(super) use_item_syntax: Option<ast::Use>,
7370

7471
/// The parent function of the cursor position if it exists.
7572
pub(super) function_def: Option<ast::Fn>,
7673
/// The parent impl of the cursor position if it exists.
7774
pub(super) impl_def: Option<ast::Impl>,
75+
pub(super) name_ref_syntax: Option<ast::NameRef>,
76+
pub(super) use_item_syntax: Option<ast::Use>,
7877

7978
// potentially set if we are completing a lifetime
8079
pub(super) lifetime_syntax: Option<ast::Lifetime>,
@@ -89,13 +88,12 @@ pub(crate) struct CompletionContext<'a> {
8988
pub(super) completion_location: Option<ImmediateLocation>,
9089
pub(super) prev_sibling: Option<ImmediatePrevSibling>,
9190
pub(super) attribute_under_caret: Option<ast::Attr>,
91+
pub(super) previous_token: Option<SyntaxToken>,
9292

9393
pub(super) path_context: Option<PathCompletionContext>,
94-
/// FIXME: `ActiveParameter` is string-based, which is very very wrong
9594
pub(super) active_parameter: Option<ActiveParameter>,
9695
pub(super) locals: Vec<(String, Local)>,
9796

98-
pub(super) previous_token: Option<SyntaxToken>,
9997
pub(super) in_loop_body: bool,
10098
pub(super) incomplete_let: bool,
10199

@@ -143,28 +141,28 @@ impl<'a> CompletionContext<'a> {
143141
original_token,
144142
token,
145143
krate,
146-
lifetime_allowed: false,
147144
expected_name: None,
148145
expected_type: None,
146+
function_def: None,
147+
impl_def: None,
149148
name_ref_syntax: None,
149+
use_item_syntax: None,
150150
lifetime_syntax: None,
151151
lifetime_param_syntax: None,
152-
function_def: None,
153-
use_item_syntax: None,
154-
impl_def: None,
155-
active_parameter: ActiveParameter::at(db, position),
152+
lifetime_allowed: false,
156153
is_label_ref: false,
157-
is_param: false,
158154
is_pat_or_const: None,
159-
path_context: None,
160-
previous_token: None,
161-
in_loop_body: false,
155+
is_param: false,
162156
completion_location: None,
163157
prev_sibling: None,
164-
no_completion_required: false,
165-
incomplete_let: false,
166158
attribute_under_caret: None,
159+
previous_token: None,
160+
path_context: None,
161+
active_parameter: ActiveParameter::at(db, position),
167162
locals,
163+
in_loop_body: false,
164+
incomplete_let: false,
165+
no_completion_required: false,
168166
};
169167

170168
let mut original_file = original_file.syntax().clone();

crates/ide_db/src/call_info.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,8 @@ impl FnCallNode {
223223
ast::Expr::PathExpr(path_expr) => path_expr.path()?.segment()?.name_ref()?,
224224
_ => return None,
225225
}),
226-
227226
FnCallNode::MethodCallExpr(call_expr) => {
228-
call_expr.syntax().children().filter_map(ast::NameRef::cast).next()
227+
call_expr.syntax().children().find_map(ast::NameRef::cast)
229228
}
230229
}
231230
}

0 commit comments

Comments
 (0)