diff options
Diffstat (limited to 'crates/ide_completion/src/context.rs')
-rw-r--r-- | crates/ide_completion/src/context.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs index 923e35dbb..faf8469a5 100644 --- a/crates/ide_completion/src/context.rs +++ b/crates/ide_completion/src/context.rs | |||
@@ -288,6 +288,10 @@ impl<'a> CompletionContext<'a> { | |||
288 | matches!(self.completion_location, Some(ImmediateLocation::ItemList)) | 288 | matches!(self.completion_location, Some(ImmediateLocation::ItemList)) |
289 | } | 289 | } |
290 | 290 | ||
291 | pub(crate) fn expects_expression(&self) -> bool { | ||
292 | self.is_expr | ||
293 | } | ||
294 | |||
291 | pub(crate) fn has_block_expr_parent(&self) -> bool { | 295 | pub(crate) fn has_block_expr_parent(&self) -> bool { |
292 | matches!(self.completion_location, Some(ImmediateLocation::BlockExpr)) | 296 | matches!(self.completion_location, Some(ImmediateLocation::BlockExpr)) |
293 | } | 297 | } |
@@ -316,7 +320,7 @@ impl<'a> CompletionContext<'a> { | |||
316 | 320 | ||
317 | fn fill_keyword_patterns(&mut self, file_with_fake_ident: &SyntaxNode, offset: TextSize) { | 321 | fn fill_keyword_patterns(&mut self, file_with_fake_ident: &SyntaxNode, offset: TextSize) { |
318 | let fake_ident_token = file_with_fake_ident.token_at_offset(offset).right_biased().unwrap(); | 322 | let fake_ident_token = file_with_fake_ident.token_at_offset(offset).right_biased().unwrap(); |
319 | let syntax_element = NodeOrToken::Token(fake_ident_token.clone()); | 323 | let syntax_element = NodeOrToken::Token(fake_ident_token); |
320 | self.previous_token = previous_token(syntax_element.clone()); | 324 | self.previous_token = previous_token(syntax_element.clone()); |
321 | self.in_loop_body = is_in_loop_body(syntax_element.clone()); | 325 | self.in_loop_body = is_in_loop_body(syntax_element.clone()); |
322 | self.is_match_arm = is_match_arm(syntax_element.clone()); | 326 | self.is_match_arm = is_match_arm(syntax_element.clone()); |
@@ -338,8 +342,6 @@ impl<'a> CompletionContext<'a> { | |||
338 | let fn_is_prev = self.previous_token_is(T![fn]); | 342 | let fn_is_prev = self.previous_token_is(T![fn]); |
339 | let for_is_prev2 = for_is_prev2(syntax_element.clone()); | 343 | let for_is_prev2 = for_is_prev2(syntax_element.clone()); |
340 | self.no_completion_required = (fn_is_prev && !inside_impl_trait_block) || for_is_prev2; | 344 | self.no_completion_required = (fn_is_prev && !inside_impl_trait_block) || for_is_prev2; |
341 | |||
342 | self.completion_location = determine_location(fake_ident_token); | ||
343 | } | 345 | } |
344 | 346 | ||
345 | fn fill_impl_def(&mut self) { | 347 | fn fill_impl_def(&mut self) { |
@@ -465,6 +467,7 @@ impl<'a> CompletionContext<'a> { | |||
465 | Some(it) => it, | 467 | Some(it) => it, |
466 | None => return, | 468 | None => return, |
467 | }; | 469 | }; |
470 | self.completion_location = determine_location(&name_like); | ||
468 | match name_like { | 471 | match name_like { |
469 | ast::NameLike::Lifetime(lifetime) => { | 472 | ast::NameLike::Lifetime(lifetime) => { |
470 | self.classify_lifetime(original_file, lifetime, offset); | 473 | self.classify_lifetime(original_file, lifetime, offset); |