aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-06-07 18:06:03 +0100
committerLukas Wirth <[email protected]>2021-06-07 18:06:03 +0100
commitaa29364f831c4633613ba7e28cae147e69107d66 (patch)
treeaf11d666532cf41e7084dd6f7f21c2cd663c809d
parent8b6c3eaaeb6b074c7cbe34f25b7736157b13f84a (diff)
Reorder CompletionContext fields
-rw-r--r--crates/ide_completion/src/context.rs30
-rw-r--r--crates/ide_db/src/call_info.rs3
2 files changed, 15 insertions, 18 deletions
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> {
67 pub(super) krate: Option<hir::Crate>, 67 pub(super) krate: Option<hir::Crate>,
68 pub(super) expected_name: Option<NameOrNameRef>, 68 pub(super) expected_name: Option<NameOrNameRef>,
69 pub(super) expected_type: Option<Type>, 69 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>,
73 70
74 /// The parent function of the cursor position if it exists. 71 /// The parent function of the cursor position if it exists.
75 pub(super) function_def: Option<ast::Fn>, 72 pub(super) function_def: Option<ast::Fn>,
76 /// The parent impl of the cursor position if it exists. 73 /// The parent impl of the cursor position if it exists.
77 pub(super) impl_def: Option<ast::Impl>, 74 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>,
78 77
79 // potentially set if we are completing a lifetime 78 // potentially set if we are completing a lifetime
80 pub(super) lifetime_syntax: Option<ast::Lifetime>, 79 pub(super) lifetime_syntax: Option<ast::Lifetime>,
@@ -89,13 +88,12 @@ pub(crate) struct CompletionContext<'a> {
89 pub(super) completion_location: Option<ImmediateLocation>, 88 pub(super) completion_location: Option<ImmediateLocation>,
90 pub(super) prev_sibling: Option<ImmediatePrevSibling>, 89 pub(super) prev_sibling: Option<ImmediatePrevSibling>,
91 pub(super) attribute_under_caret: Option<ast::Attr>, 90 pub(super) attribute_under_caret: Option<ast::Attr>,
91 pub(super) previous_token: Option<SyntaxToken>,
92 92
93 pub(super) path_context: Option<PathCompletionContext>, 93 pub(super) path_context: Option<PathCompletionContext>,
94 /// FIXME: `ActiveParameter` is string-based, which is very very wrong
95 pub(super) active_parameter: Option<ActiveParameter>, 94 pub(super) active_parameter: Option<ActiveParameter>,
96 pub(super) locals: Vec<(String, Local)>, 95 pub(super) locals: Vec<(String, Local)>,
97 96
98 pub(super) previous_token: Option<SyntaxToken>,
99 pub(super) in_loop_body: bool, 97 pub(super) in_loop_body: bool,
100 pub(super) incomplete_let: bool, 98 pub(super) incomplete_let: bool,
101 99
@@ -143,28 +141,28 @@ impl<'a> CompletionContext<'a> {
143 original_token, 141 original_token,
144 token, 142 token,
145 krate, 143 krate,
146 lifetime_allowed: false,
147 expected_name: None, 144 expected_name: None,
148 expected_type: None, 145 expected_type: None,
146 function_def: None,
147 impl_def: None,
149 name_ref_syntax: None, 148 name_ref_syntax: None,
149 use_item_syntax: None,
150 lifetime_syntax: None, 150 lifetime_syntax: None,
151 lifetime_param_syntax: None, 151 lifetime_param_syntax: None,
152 function_def: None, 152 lifetime_allowed: false,
153 use_item_syntax: None,
154 impl_def: None,
155 active_parameter: ActiveParameter::at(db, position),
156 is_label_ref: false, 153 is_label_ref: false,
157 is_param: false,
158 is_pat_or_const: None, 154 is_pat_or_const: None,
159 path_context: None, 155 is_param: false,
160 previous_token: None,
161 in_loop_body: false,
162 completion_location: None, 156 completion_location: None,
163 prev_sibling: None, 157 prev_sibling: None,
164 no_completion_required: false,
165 incomplete_let: false,
166 attribute_under_caret: None, 158 attribute_under_caret: None,
159 previous_token: None,
160 path_context: None,
161 active_parameter: ActiveParameter::at(db, position),
167 locals, 162 locals,
163 in_loop_body: false,
164 incomplete_let: false,
165 no_completion_required: false,
168 }; 166 };
169 167
170 let mut original_file = original_file.syntax().clone(); 168 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 {
223 ast::Expr::PathExpr(path_expr) => path_expr.path()?.segment()?.name_ref()?, 223 ast::Expr::PathExpr(path_expr) => path_expr.path()?.segment()?.name_ref()?,
224 _ => return None, 224 _ => return None,
225 }), 225 }),
226
227 FnCallNode::MethodCallExpr(call_expr) => { 226 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)
229 } 228 }
230 } 229 }
231 } 230 }