Skip to content

Commit a7d7546

Browse files
Fix the tests
1 parent 5aebf54 commit a7d7546

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

crates/ide/src/completion/complete_attribute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::completion::{
1313
};
1414

1515
pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
16-
if ctx.mod_under_caret.is_some() {
16+
if ctx.mod_declaration_under_caret.is_some() {
1717
return None;
1818
}
1919

crates/ide/src/completion/complete_mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use super::{
1414

1515
/// Complete mod declaration, i.e. `mod <|> ;`
1616
pub(super) fn complete_mod(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
17-
let mod_under_caret = match &ctx.mod_under_caret {
17+
let mod_under_caret = match &ctx.mod_declaration_under_caret {
1818
Some(mod_under_caret) if mod_under_caret.item_list().is_some() => return None,
1919
Some(mod_under_caret) => mod_under_caret,
2020
None => return None,

crates/ide/src/completion/complete_qualified_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub(super) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
1313
None => return,
1414
};
1515

16-
if ctx.attribute_under_caret.is_some() || ctx.mod_under_caret.is_some() {
16+
if ctx.attribute_under_caret.is_some() || ctx.mod_declaration_under_caret.is_some() {
1717
return;
1818
}
1919

crates/ide/src/completion/complete_unqualified_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub(super) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC
1313
if ctx.record_lit_syntax.is_some()
1414
|| ctx.record_pat_syntax.is_some()
1515
|| ctx.attribute_under_caret.is_some()
16-
|| ctx.mod_under_caret.is_some()
16+
|| ctx.mod_declaration_under_caret.is_some()
1717
{
1818
return;
1919
}

crates/ide/src/completion/completion_context.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub(crate) struct CompletionContext<'a> {
7777
pub(super) is_path_type: bool,
7878
pub(super) has_type_args: bool,
7979
pub(super) attribute_under_caret: Option<ast::Attr>,
80-
pub(super) mod_under_caret: Option<ast::Module>,
80+
pub(super) mod_declaration_under_caret: Option<ast::Module>,
8181
pub(super) unsafe_is_prev: bool,
8282
pub(super) if_is_prev: bool,
8383
pub(super) block_expr_parent: bool,
@@ -153,7 +153,7 @@ impl<'a> CompletionContext<'a> {
153153
has_type_args: false,
154154
dot_receiver_is_ambiguous_float_literal: false,
155155
attribute_under_caret: None,
156-
mod_under_caret: None,
156+
mod_declaration_under_caret: None,
157157
unsafe_is_prev: false,
158158
in_loop_body: false,
159159
ref_pat_parent: false,
@@ -241,7 +241,9 @@ impl<'a> CompletionContext<'a> {
241241
self.is_match_arm = is_match_arm(syntax_element.clone());
242242
self.has_item_list_or_source_file_parent =
243243
has_item_list_or_source_file_parent(syntax_element.clone());
244-
self.mod_under_caret = find_node_at_offset(&file_with_fake_ident, offset);
244+
self.mod_declaration_under_caret =
245+
find_node_at_offset::<ast::Module>(&file_with_fake_ident, offset)
246+
.filter(|module| module.item_list().is_none());
245247
}
246248

247249
fn fill(

0 commit comments

Comments
 (0)