aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/context.rs
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-05-27 02:47:20 +0100
committerLukas Wirth <[email protected]>2021-05-27 02:47:20 +0100
commit30948e1ecb2fb4fe35bf9c5c1e49464d4ea1d064 (patch)
tree3192e07f5e0bd772e47f65be732fa8fd590b3e8b /crates/ide_completion/src/context.rs
parent6ec4ea8d9eb9ad6ad8b91968bde09121b5b791a0 (diff)
simplify
Diffstat (limited to 'crates/ide_completion/src/context.rs')
-rw-r--r--crates/ide_completion/src/context.rs13
1 files changed, 10 insertions, 3 deletions
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> {
115 pub(super) is_path_type: bool, 115 pub(super) is_path_type: bool,
116 pub(super) has_type_args: bool, 116 pub(super) has_type_args: bool,
117 pub(super) attribute_under_caret: Option<ast::Attr>, 117 pub(super) attribute_under_caret: Option<ast::Attr>,
118 pub(super) locals: Vec<(String, Local)>,
119
120 pub(super) mod_declaration_under_caret: Option<ast::Module>, 118 pub(super) mod_declaration_under_caret: Option<ast::Module>,
119 pub(super) locals: Vec<(String, Local)>,
121 120
122 // keyword patterns 121 // keyword patterns
123 pub(super) previous_token: Option<SyntaxToken>, 122 pub(super) previous_token: Option<SyntaxToken>,
124 pub(super) in_loop_body: bool,
125 pub(super) prev_sibling: Option<PrevSibling>, 123 pub(super) prev_sibling: Option<PrevSibling>,
124 pub(super) in_loop_body: bool,
126 pub(super) is_match_arm: bool, 125 pub(super) is_match_arm: bool,
127 pub(super) incomplete_let: bool, 126 pub(super) incomplete_let: bool,
128 127
@@ -316,6 +315,14 @@ impl<'a> CompletionContext<'a> {
316 self.prev_sibling.is_some() 315 self.prev_sibling.is_some()
317 } 316 }
318 317
318 pub(crate) fn is_path_disallowed(&self) -> bool {
319 self.record_lit_syntax.is_some()
320 || self.record_pat_syntax.is_some()
321 || self.attribute_under_caret.is_some()
322 || self.mod_declaration_under_caret.is_some()
323 || self.has_impl_or_trait_parent()
324 }
325
319 fn fill_keyword_patterns(&mut self, file_with_fake_ident: &SyntaxNode, offset: TextSize) { 326 fn fill_keyword_patterns(&mut self, file_with_fake_ident: &SyntaxNode, offset: TextSize) {
320 let fake_ident_token = file_with_fake_ident.token_at_offset(offset).right_biased().unwrap(); 327 let fake_ident_token = file_with_fake_ident.token_at_offset(offset).right_biased().unwrap();
321 let syntax_element = NodeOrToken::Token(fake_ident_token); 328 let syntax_element = NodeOrToken::Token(fake_ident_token);