From 30948e1ecb2fb4fe35bf9c5c1e49464d4ea1d064 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 27 May 2021 03:47:20 +0200 Subject: simplify --- crates/ide_completion/src/context.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'crates/ide_completion/src/context.rs') diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs index 5d15fde2f..66577df94 100644 --- a/crates/ide_completion/src/context.rs +++ b/crates/ide_completion/src/context.rs @@ -115,14 +115,13 @@ pub(crate) struct CompletionContext<'a> { pub(super) is_path_type: bool, pub(super) has_type_args: bool, pub(super) attribute_under_caret: Option, - pub(super) locals: Vec<(String, Local)>, - pub(super) mod_declaration_under_caret: Option, + pub(super) locals: Vec<(String, Local)>, // keyword patterns pub(super) previous_token: Option, - pub(super) in_loop_body: bool, pub(super) prev_sibling: Option, + pub(super) in_loop_body: bool, pub(super) is_match_arm: bool, pub(super) incomplete_let: bool, @@ -316,6 +315,14 @@ impl<'a> CompletionContext<'a> { self.prev_sibling.is_some() } + pub(crate) fn is_path_disallowed(&self) -> bool { + self.record_lit_syntax.is_some() + || self.record_pat_syntax.is_some() + || self.attribute_under_caret.is_some() + || self.mod_declaration_under_caret.is_some() + || self.has_impl_or_trait_parent() + } + fn fill_keyword_patterns(&mut self, file_with_fake_ident: &SyntaxNode, offset: TextSize) { let fake_ident_token = file_with_fake_ident.token_at_offset(offset).right_biased().unwrap(); let syntax_element = NodeOrToken::Token(fake_ident_token); -- cgit v1.2.3