diff options
Diffstat (limited to 'crates/ide_completion/src/context.rs')
-rw-r--r-- | crates/ide_completion/src/context.rs | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs index 20e033d31..7e4b14926 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(); |
@@ -563,10 +561,6 @@ impl<'a> CompletionContext<'a> { | |||
563 | self.name_ref_syntax = | 561 | self.name_ref_syntax = |
564 | find_node_at_offset(original_file, name_ref.syntax().text_range().start()); | 562 | find_node_at_offset(original_file, name_ref.syntax().text_range().start()); |
565 | 563 | ||
566 | if matches!(self.completion_location, Some(ImmediateLocation::ItemList)) { | ||
567 | return; | ||
568 | } | ||
569 | |||
570 | self.use_item_syntax = | 564 | self.use_item_syntax = |
571 | self.sema.token_ancestors_with_macros(self.token.clone()).find_map(ast::Use::cast); | 565 | self.sema.token_ancestors_with_macros(self.token.clone()).find_map(ast::Use::cast); |
572 | 566 | ||
@@ -597,7 +591,7 @@ impl<'a> CompletionContext<'a> { | |||
597 | path_ctx.call_kind = match_ast! { | 591 | path_ctx.call_kind = match_ast! { |
598 | match p { | 592 | match p { |
599 | ast::PathExpr(it) => it.syntax().parent().and_then(ast::CallExpr::cast).map(|_| CallKind::Expr), | 593 | ast::PathExpr(it) => it.syntax().parent().and_then(ast::CallExpr::cast).map(|_| CallKind::Expr), |
600 | ast::MacroCall(_it) => Some(CallKind::Mac), | 594 | ast::MacroCall(it) => it.excl_token().and(Some(CallKind::Mac)), |
601 | ast::TupleStructPat(_it) => Some(CallKind::Pat), | 595 | ast::TupleStructPat(_it) => Some(CallKind::Pat), |
602 | _ => None | 596 | _ => None |
603 | } | 597 | } |