From a7d75463c7d1473e4276601688baa22c10eec255 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 8 Sep 2020 02:34:11 +0300 Subject: Fix the tests --- crates/ide/src/completion/complete_attribute.rs | 2 +- crates/ide/src/completion/complete_mod.rs | 2 +- crates/ide/src/completion/complete_qualified_path.rs | 2 +- crates/ide/src/completion/complete_unqualified_path.rs | 2 +- crates/ide/src/completion/completion_context.rs | 8 +++++--- 5 files changed, 9 insertions(+), 7 deletions(-) (limited to 'crates/ide/src') diff --git a/crates/ide/src/completion/complete_attribute.rs b/crates/ide/src/completion/complete_attribute.rs index ef4fb6a91..f4a9864d1 100644 --- a/crates/ide/src/completion/complete_attribute.rs +++ b/crates/ide/src/completion/complete_attribute.rs @@ -13,7 +13,7 @@ use crate::completion::{ }; pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { - if ctx.mod_under_caret.is_some() { + if ctx.mod_declaration_under_caret.is_some() { return None; } diff --git a/crates/ide/src/completion/complete_mod.rs b/crates/ide/src/completion/complete_mod.rs index 049e99674..d457ff6bf 100644 --- a/crates/ide/src/completion/complete_mod.rs +++ b/crates/ide/src/completion/complete_mod.rs @@ -14,7 +14,7 @@ use super::{ /// Complete mod declaration, i.e. `mod <|> ;` pub(super) fn complete_mod(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { - let mod_under_caret = match &ctx.mod_under_caret { + let mod_under_caret = match &ctx.mod_declaration_under_caret { Some(mod_under_caret) if mod_under_caret.item_list().is_some() => return None, Some(mod_under_caret) => mod_under_caret, None => return None, diff --git a/crates/ide/src/completion/complete_qualified_path.rs b/crates/ide/src/completion/complete_qualified_path.rs index 184488a73..79de50792 100644 --- a/crates/ide/src/completion/complete_qualified_path.rs +++ b/crates/ide/src/completion/complete_qualified_path.rs @@ -13,7 +13,7 @@ pub(super) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon None => return, }; - if ctx.attribute_under_caret.is_some() || ctx.mod_under_caret.is_some() { + if ctx.attribute_under_caret.is_some() || ctx.mod_declaration_under_caret.is_some() { return; } diff --git a/crates/ide/src/completion/complete_unqualified_path.rs b/crates/ide/src/completion/complete_unqualified_path.rs index f2189dfde..8eda4b64d 100644 --- a/crates/ide/src/completion/complete_unqualified_path.rs +++ b/crates/ide/src/completion/complete_unqualified_path.rs @@ -13,7 +13,7 @@ pub(super) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC if ctx.record_lit_syntax.is_some() || ctx.record_pat_syntax.is_some() || ctx.attribute_under_caret.is_some() - || ctx.mod_under_caret.is_some() + || ctx.mod_declaration_under_caret.is_some() { return; } diff --git a/crates/ide/src/completion/completion_context.rs b/crates/ide/src/completion/completion_context.rs index ea4830843..161f59c1e 100644 --- a/crates/ide/src/completion/completion_context.rs +++ b/crates/ide/src/completion/completion_context.rs @@ -77,7 +77,7 @@ 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) mod_under_caret: Option, + pub(super) mod_declaration_under_caret: Option, pub(super) unsafe_is_prev: bool, pub(super) if_is_prev: bool, pub(super) block_expr_parent: bool, @@ -153,7 +153,7 @@ impl<'a> CompletionContext<'a> { has_type_args: false, dot_receiver_is_ambiguous_float_literal: false, attribute_under_caret: None, - mod_under_caret: None, + mod_declaration_under_caret: None, unsafe_is_prev: false, in_loop_body: false, ref_pat_parent: false, @@ -241,7 +241,9 @@ impl<'a> CompletionContext<'a> { self.is_match_arm = is_match_arm(syntax_element.clone()); self.has_item_list_or_source_file_parent = has_item_list_or_source_file_parent(syntax_element.clone()); - self.mod_under_caret = find_node_at_offset(&file_with_fake_ident, offset); + self.mod_declaration_under_caret = + find_node_at_offset::(&file_with_fake_ident, offset) + .filter(|module| module.item_list().is_none()); } fn fill( -- cgit v1.2.3