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.rs26
1 files changed, 18 insertions, 8 deletions
diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs
index a8437d81c..121909857 100644
--- a/crates/ide_completion/src/context.rs
+++ b/crates/ide_completion/src/context.rs
@@ -302,18 +302,28 @@ impl<'a> CompletionContext<'a> {
302 ) 302 )
303 } 303 }
304 304
305 pub(crate) fn has_visibility_prev_sibling(&self) -> bool {
306 matches!(self.prev_sibling, Some(ImmediatePrevSibling::Visibility))
307 }
308
305 pub(crate) fn after_if(&self) -> bool { 309 pub(crate) fn after_if(&self) -> bool {
306 matches!(self.prev_sibling, Some(ImmediatePrevSibling::IfExpr)) 310 matches!(self.prev_sibling, Some(ImmediatePrevSibling::IfExpr))
307 } 311 }
308 312
309 pub(crate) fn is_path_disallowed(&self) -> bool { 313 pub(crate) fn is_path_disallowed(&self) -> bool {
310 matches!( 314 self.attribute_under_caret.is_some()
311 self.completion_location, 315 || self.previous_token_is(T![unsafe])
312 Some(ImmediateLocation::Attribute(_)) 316 || matches!(
313 | Some(ImmediateLocation::ModDeclaration(_)) 317 self.prev_sibling,
314 | Some(ImmediateLocation::RecordPat(_)) 318 Some(ImmediatePrevSibling::Attribute) | Some(ImmediatePrevSibling::Visibility)
315 | Some(ImmediateLocation::RecordExpr(_)) 319 )
316 ) || self.attribute_under_caret.is_some() 320 || matches!(
321 self.completion_location,
322 Some(ImmediateLocation::Attribute(_))
323 | Some(ImmediateLocation::ModDeclaration(_))
324 | Some(ImmediateLocation::RecordPat(_))
325 | Some(ImmediateLocation::RecordExpr(_))
326 )
317 } 327 }
318 328
319 pub(crate) fn expects_expression(&self) -> bool { 329 pub(crate) fn expects_expression(&self) -> bool {
@@ -685,7 +695,7 @@ mod tests {
685 use expect_test::{expect, Expect}; 695 use expect_test::{expect, Expect};
686 use hir::HirDisplay; 696 use hir::HirDisplay;
687 697
688 use crate::test_utils::{position, TEST_CONFIG}; 698 use crate::tests::{position, TEST_CONFIG};
689 699
690 use super::CompletionContext; 700 use super::CompletionContext;
691 701