diff options
author | Lukas Wirth <[email protected]> | 2021-06-07 19:45:17 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-06-07 19:45:17 +0100 |
commit | 2987e05f158207f63e2bc4ac87c0c2fbb7e61002 (patch) | |
tree | 0a37f8a451dcd9cebc8024af9c2a9d98f0449312 /crates/ide_completion/src/context.rs | |
parent | b29e8ed994c573273a8182efd9b74ec8c664a848 (diff) |
simplify
Diffstat (limited to 'crates/ide_completion/src/context.rs')
-rw-r--r-- | crates/ide_completion/src/context.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs index 7e4b14926..6177caa12 100644 --- a/crates/ide_completion/src/context.rs +++ b/crates/ide_completion/src/context.rs | |||
@@ -43,6 +43,7 @@ pub(crate) struct PathCompletionContext { | |||
43 | pub(super) can_be_stmt: bool, | 43 | pub(super) can_be_stmt: bool, |
44 | /// `true` if we expect an expression at the cursor position. | 44 | /// `true` if we expect an expression at the cursor position. |
45 | pub(super) is_expr: bool, | 45 | pub(super) is_expr: bool, |
46 | pub(super) in_loop_body: bool, | ||
46 | } | 47 | } |
47 | 48 | ||
48 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] | 49 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] |
@@ -94,7 +95,6 @@ pub(crate) struct CompletionContext<'a> { | |||
94 | pub(super) active_parameter: Option<ActiveParameter>, | 95 | pub(super) active_parameter: Option<ActiveParameter>, |
95 | pub(super) locals: Vec<(String, Local)>, | 96 | pub(super) locals: Vec<(String, Local)>, |
96 | 97 | ||
97 | pub(super) in_loop_body: bool, | ||
98 | pub(super) incomplete_let: bool, | 98 | pub(super) incomplete_let: bool, |
99 | 99 | ||
100 | no_completion_required: bool, | 100 | no_completion_required: bool, |
@@ -160,7 +160,6 @@ impl<'a> CompletionContext<'a> { | |||
160 | path_context: None, | 160 | path_context: None, |
161 | active_parameter: ActiveParameter::at(db, position), | 161 | active_parameter: ActiveParameter::at(db, position), |
162 | locals, | 162 | locals, |
163 | in_loop_body: false, | ||
164 | incomplete_let: false, | 163 | incomplete_let: false, |
165 | no_completion_required: false, | 164 | no_completion_required: false, |
166 | }; | 165 | }; |
@@ -324,10 +323,6 @@ impl<'a> CompletionContext<'a> { | |||
324 | self.path_context.as_ref().and_then(|it| it.path_qual.as_ref()) | 323 | self.path_context.as_ref().and_then(|it| it.path_qual.as_ref()) |
325 | } | 324 | } |
326 | 325 | ||
327 | pub(crate) fn can_be_stmt(&self) -> bool { | ||
328 | self.path_context.as_ref().map_or(false, |it| it.can_be_stmt) | ||
329 | } | ||
330 | |||
331 | fn fill_impl_def(&mut self) { | 326 | fn fill_impl_def(&mut self) { |
332 | self.impl_def = self | 327 | self.impl_def = self |
333 | .sema | 328 | .sema |
@@ -453,7 +448,6 @@ impl<'a> CompletionContext<'a> { | |||
453 | let for_is_prev2 = for_is_prev2(syntax_element.clone()); | 448 | let for_is_prev2 = for_is_prev2(syntax_element.clone()); |
454 | (fn_is_prev && !inside_impl_trait_block) || for_is_prev2 | 449 | (fn_is_prev && !inside_impl_trait_block) || for_is_prev2 |
455 | }; | 450 | }; |
456 | self.in_loop_body = is_in_loop_body(syntax_element.clone()); | ||
457 | 451 | ||
458 | self.incomplete_let = | 452 | self.incomplete_let = |
459 | syntax_element.ancestors().take(6).find_map(ast::LetStmt::cast).map_or(false, |it| { | 453 | syntax_element.ancestors().take(6).find_map(ast::LetStmt::cast).map_or(false, |it| { |
@@ -584,7 +578,9 @@ impl<'a> CompletionContext<'a> { | |||
584 | is_path_type: false, | 578 | is_path_type: false, |
585 | can_be_stmt: false, | 579 | can_be_stmt: false, |
586 | is_expr: false, | 580 | is_expr: false, |
581 | in_loop_body: false, | ||
587 | }); | 582 | }); |
583 | path_ctx.in_loop_body = is_in_loop_body(name_ref.syntax()); | ||
588 | let path = segment.parent_path(); | 584 | let path = segment.parent_path(); |
589 | 585 | ||
590 | if let Some(p) = path.syntax().parent() { | 586 | if let Some(p) = path.syntax().parent() { |