@@ -36,9 +36,9 @@ use crate::{
3636 const_:: render_const,
3737 function:: { render_fn, render_method} ,
3838 literal:: { render_struct_literal, render_variant_lit} ,
39- macro_:: render_macro,
39+ macro_:: { render_macro, render_macro_pat } ,
4040 pattern:: { render_struct_pat, render_variant_pat} ,
41- render_field, render_path_resolution, render_resolution_simple , render_tuple_field,
41+ render_field, render_path_resolution, render_pattern_resolution , render_tuple_field,
4242 type_alias:: { render_type_alias, render_type_alias_with_eq} ,
4343 union_literal:: render_union_literal,
4444 RenderContext ,
@@ -134,10 +134,14 @@ impl Completions {
134134 item. add_to ( self ) ;
135135 }
136136
137- pub ( crate ) fn add_crate_roots ( & mut self , ctx : & CompletionContext ) {
137+ pub ( crate ) fn add_crate_roots (
138+ & mut self ,
139+ ctx : & CompletionContext ,
140+ path_ctx : & PathCompletionCtx ,
141+ ) {
138142 ctx. process_all_names ( & mut |name, res| match res {
139143 ScopeDef :: ModuleDef ( hir:: ModuleDef :: Module ( m) ) if m. is_crate_root ( ctx. db ) => {
140- self . add_module ( ctx, m, name) ;
144+ self . add_module ( ctx, path_ctx , m, name) ;
141145 }
142146 _ => ( ) ,
143147 } ) ;
@@ -160,25 +164,36 @@ impl Completions {
160164 ) ;
161165 }
162166
163- pub ( crate ) fn add_resolution_simple (
167+ pub ( crate ) fn add_pattern_resolution (
164168 & mut self ,
165169 ctx : & CompletionContext ,
170+ pattern_ctx : & PatternContext ,
166171 local_name : hir:: Name ,
167172 resolution : hir:: ScopeDef ,
168173 ) {
169174 if ctx. is_scope_def_hidden ( resolution) {
175+ cov_mark:: hit!( qualified_path_doc_hidden) ;
170176 return ;
171177 }
172- self . add ( render_resolution_simple ( RenderContext :: new ( ctx) , local_name, resolution) . build ( ) ) ;
178+ self . add (
179+ render_pattern_resolution ( RenderContext :: new ( ctx) , pattern_ctx, local_name, resolution)
180+ . build ( ) ,
181+ ) ;
173182 }
174183
175184 pub ( crate ) fn add_module (
176185 & mut self ,
177186 ctx : & CompletionContext ,
187+ path_ctx : & PathCompletionCtx ,
178188 module : hir:: Module ,
179189 local_name : hir:: Name ,
180190 ) {
181- self . add_resolution_simple ( ctx, local_name, hir:: ScopeDef :: ModuleDef ( module. into ( ) ) ) ;
191+ self . add_path_resolution (
192+ ctx,
193+ path_ctx,
194+ local_name,
195+ hir:: ScopeDef :: ModuleDef ( module. into ( ) ) ,
196+ ) ;
182197 }
183198
184199 pub ( crate ) fn add_macro (
@@ -204,6 +219,29 @@ impl Completions {
204219 ) ;
205220 }
206221
222+ pub ( crate ) fn add_macro_pat (
223+ & mut self ,
224+ ctx : & CompletionContext ,
225+ pattern_ctx : & PatternContext ,
226+ mac : hir:: Macro ,
227+ local_name : hir:: Name ,
228+ ) {
229+ let is_private_editable = match ctx. is_visible ( & mac) {
230+ Visible :: Yes => false ,
231+ Visible :: Editable => true ,
232+ Visible :: No => return ,
233+ } ;
234+ self . add (
235+ render_macro_pat (
236+ RenderContext :: new ( ctx) . private_editable ( is_private_editable) ,
237+ pattern_ctx,
238+ local_name,
239+ mac,
240+ )
241+ . build ( ) ,
242+ ) ;
243+ }
244+
207245 pub ( crate ) fn add_function (
208246 & mut self ,
209247 ctx : & CompletionContext ,
@@ -341,6 +379,7 @@ impl Completions {
341379 pub ( crate ) fn add_field (
342380 & mut self ,
343381 ctx : & CompletionContext ,
382+ dot_access : & DotAccess ,
344383 receiver : Option < hir:: Name > ,
345384 field : hir:: Field ,
346385 ty : & hir:: Type ,
@@ -352,6 +391,7 @@ impl Completions {
352391 } ;
353392 let item = render_field (
354393 RenderContext :: new ( ctx) . private_editable ( is_private_editable) ,
394+ dot_access,
355395 receiver,
356396 field,
357397 ty,
0 commit comments