@@ -11,6 +11,7 @@ use crate::{
1111 use_segment_positions:: {
1212 use_completion_item_additional_text_edits, UseCompletionItemAdditionTextEditsRequest ,
1313 } ,
14+ visibility:: module_def_id_is_visible,
1415} ;
1516
1617use super :: CodeActionFinder ;
@@ -41,6 +42,16 @@ impl<'a> CodeActionFinder<'a> {
4142 }
4243
4344 for ( module_def_id, visibility, defining_module) in entries {
45+ if !module_def_id_is_visible (
46+ * module_def_id,
47+ self . module_id ,
48+ * visibility,
49+ self . interner ,
50+ self . def_maps ,
51+ ) {
52+ continue ;
53+ }
54+
4455 let module_full_path = if let Some ( defining_module) = defining_module {
4556 relative_module_id_path (
4657 * defining_module,
@@ -51,11 +62,9 @@ impl<'a> CodeActionFinder<'a> {
5162 } else {
5263 let Some ( module_full_path) = relative_module_full_path (
5364 * module_def_id,
54- * visibility,
5565 self . module_id ,
5666 current_module_parent_id,
5767 self . interner ,
58- self . def_maps ,
5968 ) else {
6069 continue ;
6170 } ;
@@ -132,7 +141,7 @@ mod tests {
132141
133142 let src = r#"
134143 mod foo {
135- mod bar {
144+ pub mod bar {
136145 pub struct SomeTypeInBar {}
137146 }
138147 }
@@ -142,7 +151,7 @@ mod tests {
142151
143152 let expected = r#"
144153 mod foo {
145- mod bar {
154+ pub mod bar {
146155 pub struct SomeTypeInBar {}
147156 }
148157 }
@@ -158,7 +167,7 @@ mod tests {
158167 let title = "Import foo::bar::SomeTypeInBar" ;
159168
160169 let src = r#"mod foo {
161- mod bar {
170+ pub mod bar {
162171 pub struct SomeTypeInBar {}
163172 }
164173}
@@ -168,7 +177,7 @@ fn foo(x: SomeType>|<InBar) {}"#;
168177 let expected = r#"use foo::bar::SomeTypeInBar;
169178
170179mod foo {
171- mod bar {
180+ pub mod bar {
172181 pub struct SomeTypeInBar {}
173182 }
174183}
@@ -184,7 +193,7 @@ fn foo(x: SomeTypeInBar) {}"#;
184193
185194 let src = r#"
186195 mod foo {
187- mod bar {
196+ pub mod bar {
188197 pub mod some_module_in_bar {}
189198 }
190199 }
@@ -196,7 +205,7 @@ fn foo(x: SomeTypeInBar) {}"#;
196205
197206 let expected = r#"
198207 mod foo {
199- mod bar {
208+ pub mod bar {
200209 pub mod some_module_in_bar {}
201210 }
202211 }
@@ -214,7 +223,7 @@ fn foo(x: SomeTypeInBar) {}"#;
214223 let title = "Import foo::bar::some_module_in_bar" ;
215224
216225 let src = r#"mod foo {
217- mod bar {
226+ pub mod bar {
218227 pub(crate) mod some_module_in_bar {}
219228 }
220229}
@@ -226,7 +235,7 @@ fn main() {
226235 let expected = r#"use foo::bar::some_module_in_bar;
227236
228237mod foo {
229- mod bar {
238+ pub mod bar {
230239 pub(crate) mod some_module_in_bar {}
231240 }
232241}
@@ -245,7 +254,7 @@ fn main() {
245254 let src = r#"use foo::bar::SomeOtherType;
246255
247256mod foo {
248- mod bar {
257+ pub mod bar {
249258 pub struct SomeTypeInBar {}
250259 }
251260}
@@ -255,7 +264,7 @@ fn foo(x: SomeType>|<InBar) {}"#;
255264 let expected = r#"use foo::bar::{SomeOtherType, SomeTypeInBar};
256265
257266mod foo {
258- mod bar {
267+ pub mod bar {
259268 pub struct SomeTypeInBar {}
260269 }
261270}
0 commit comments