@@ -28,22 +28,40 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
28
28
29
29
let context_module = ctx. scope . module ( ) ;
30
30
31
- if let Some ( ImmediateLocation :: ItemList | ImmediateLocation :: Trait | ImmediateLocation :: Impl ) =
32
- ctx. completion_location
33
- {
34
- if let hir:: PathResolution :: Def ( hir:: ModuleDef :: Module ( module) ) = resolution {
35
- for ( name, def) in module. scope ( ctx. db , context_module) {
36
- if let hir:: ScopeDef :: MacroDef ( macro_def) = def {
37
- if macro_def. is_fn_like ( ) {
38
- acc. add_macro ( ctx, Some ( name. clone ( ) ) , macro_def) ;
31
+ match ctx. completion_location {
32
+ Some ( ImmediateLocation :: ItemList | ImmediateLocation :: Trait | ImmediateLocation :: Impl ) => {
33
+ if let hir:: PathResolution :: Def ( hir:: ModuleDef :: Module ( module) ) = resolution {
34
+ for ( name, def) in module. scope ( ctx. db , context_module) {
35
+ if let hir:: ScopeDef :: MacroDef ( macro_def) = def {
36
+ if macro_def. is_fn_like ( ) {
37
+ acc. add_macro ( ctx, Some ( name. clone ( ) ) , macro_def) ;
38
+ }
39
+ }
40
+ if let hir:: ScopeDef :: ModuleDef ( hir:: ModuleDef :: Module ( _) ) = def {
41
+ acc. add_resolution ( ctx, name, & def) ;
39
42
}
40
43
}
41
- if let hir:: ScopeDef :: ModuleDef ( hir:: ModuleDef :: Module ( _) ) = def {
42
- acc. add_resolution ( ctx, name, & def) ;
44
+ }
45
+ return ;
46
+ }
47
+ Some ( ImmediateLocation :: Visibility ( _) ) => {
48
+ if let hir:: PathResolution :: Def ( hir:: ModuleDef :: Module ( resolved) ) = resolution {
49
+ if let Some ( current_module) = ctx. scope . module ( ) {
50
+ if let Some ( next) = current_module
51
+ . path_to_root ( ctx. db )
52
+ . into_iter ( )
53
+ . take_while ( |& it| it != resolved)
54
+ . next ( )
55
+ {
56
+ if let Some ( name) = next. name ( ctx. db ) {
57
+ acc. add_resolution ( ctx, name, & hir:: ScopeDef :: ModuleDef ( next. into ( ) ) ) ;
58
+ }
59
+ }
43
60
}
44
61
}
62
+ return ;
45
63
}
46
- return ;
64
+ _ => ( ) ,
47
65
}
48
66
49
67
if ctx. in_use_tree ( ) {
0 commit comments