aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/context.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/context.rs')
-rw-r--r--crates/ide_completion/src/context.rs31
1 files changed, 16 insertions, 15 deletions
diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs
index 240cac1de..84b2bcf9f 100644
--- a/crates/ide_completion/src/context.rs
+++ b/crates/ide_completion/src/context.rs
@@ -242,24 +242,23 @@ impl<'a> CompletionContext<'a> {
242 } 242 }
243 243
244 pub(crate) fn expects_assoc_item(&self) -> bool { 244 pub(crate) fn expects_assoc_item(&self) -> bool {
245 matches!( 245 matches!(self.completion_location, Some(ImmediateLocation::Trait | ImmediateLocation::Impl))
246 self.completion_location,
247 Some(ImmediateLocation::Trait) | Some(ImmediateLocation::Impl)
248 )
249 } 246 }
250 247
251 pub(crate) fn has_dot_receiver(&self) -> bool { 248 pub(crate) fn has_dot_receiver(&self) -> bool {
252 matches!( 249 matches!(
253 &self.completion_location, 250 &self.completion_location,
254 Some(ImmediateLocation::FieldAccess { receiver, .. }) | Some(ImmediateLocation::MethodCall { receiver,.. }) 251 Some(ImmediateLocation::FieldAccess { receiver, .. } | ImmediateLocation::MethodCall { receiver,.. })
255 if receiver.is_some() 252 if receiver.is_some()
256 ) 253 )
257 } 254 }
258 255
259 pub(crate) fn dot_receiver(&self) -> Option<&ast::Expr> { 256 pub(crate) fn dot_receiver(&self) -> Option<&ast::Expr> {
260 match &self.completion_location { 257 match &self.completion_location {
261 Some(ImmediateLocation::MethodCall { receiver, .. }) 258 Some(
262 | Some(ImmediateLocation::FieldAccess { receiver, .. }) => receiver.as_ref(), 259 ImmediateLocation::MethodCall { receiver, .. }
260 | ImmediateLocation::FieldAccess { receiver, .. },
261 ) => receiver.as_ref(),
263 _ => None, 262 _ => None,
264 } 263 }
265 } 264 }
@@ -283,7 +282,7 @@ impl<'a> CompletionContext<'a> {
283 pub(crate) fn expects_ident_pat_or_ref_expr(&self) -> bool { 282 pub(crate) fn expects_ident_pat_or_ref_expr(&self) -> bool {
284 matches!( 283 matches!(
285 self.completion_location, 284 self.completion_location,
286 Some(ImmediateLocation::IdentPat) | Some(ImmediateLocation::RefExpr) 285 Some(ImmediateLocation::IdentPat | ImmediateLocation::RefExpr)
287 ) 286 )
288 } 287 }
289 288
@@ -294,14 +293,14 @@ impl<'a> CompletionContext<'a> {
294 pub(crate) fn in_use_tree(&self) -> bool { 293 pub(crate) fn in_use_tree(&self) -> bool {
295 matches!( 294 matches!(
296 self.completion_location, 295 self.completion_location,
297 Some(ImmediateLocation::Use) | Some(ImmediateLocation::UseTree) 296 Some(ImmediateLocation::Use | ImmediateLocation::UseTree)
298 ) 297 )
299 } 298 }
300 299
301 pub(crate) fn has_impl_or_trait_prev_sibling(&self) -> bool { 300 pub(crate) fn has_impl_or_trait_prev_sibling(&self) -> bool {
302 matches!( 301 matches!(
303 self.prev_sibling, 302 self.prev_sibling,
304 Some(ImmediatePrevSibling::ImplDefType) | Some(ImmediatePrevSibling::TraitDefName) 303 Some(ImmediatePrevSibling::ImplDefType | ImmediatePrevSibling::TraitDefName)
305 ) 304 )
306 } 305 }
307 306
@@ -318,14 +317,16 @@ impl<'a> CompletionContext<'a> {
318 || self.previous_token_is(T![unsafe]) 317 || self.previous_token_is(T![unsafe])
319 || matches!( 318 || matches!(
320 self.prev_sibling, 319 self.prev_sibling,
321 Some(ImmediatePrevSibling::Attribute) | Some(ImmediatePrevSibling::Visibility) 320 Some(ImmediatePrevSibling::Attribute | ImmediatePrevSibling::Visibility)
322 ) 321 )
323 || matches!( 322 || matches!(
324 self.completion_location, 323 self.completion_location,
325 Some(ImmediateLocation::Attribute(_)) 324 Some(
326 | Some(ImmediateLocation::ModDeclaration(_)) 325 ImmediateLocation::Attribute(_)
327 | Some(ImmediateLocation::RecordPat(_)) 326 | ImmediateLocation::ModDeclaration(_)
328 | Some(ImmediateLocation::RecordExpr(_)) 327 | ImmediateLocation::RecordPat(_)
328 | ImmediateLocation::RecordExpr(_)
329 )
329 ) 330 )
330 } 331 }
331 332