@@ -29,11 +29,11 @@ use crate::{
29
29
item:: Builder ,
30
30
render:: {
31
31
const_:: render_const,
32
- enum_variant:: render_variant,
33
32
function:: { render_fn, render_method} ,
33
+ literal:: { render_struct_literal, render_variant_lit} ,
34
+ macro_:: render_macro,
34
35
pattern:: { render_struct_pat, render_variant_pat} ,
35
- render_field, render_resolution, render_tuple_field,
36
- struct_literal:: render_struct_literal,
36
+ render_field, render_resolution, render_resolution_simple, render_tuple_field,
37
37
type_alias:: { render_type_alias, render_type_alias_with_eq} ,
38
38
union_literal:: render_union_literal,
39
39
RenderContext ,
@@ -124,7 +124,37 @@ impl Completions {
124
124
cov_mark:: hit!( qualified_path_doc_hidden) ;
125
125
return ;
126
126
}
127
- self . add ( render_resolution ( RenderContext :: new ( ctx, false ) , local_name, resolution) ) ;
127
+ self . add ( render_resolution ( RenderContext :: new ( ctx) , local_name, resolution) ) ;
128
+ }
129
+
130
+ pub ( crate ) fn add_resolution_simple (
131
+ & mut self ,
132
+ ctx : & CompletionContext ,
133
+ local_name : hir:: Name ,
134
+ resolution : hir:: ScopeDef ,
135
+ ) {
136
+ if ctx. is_scope_def_hidden ( resolution) {
137
+ return ;
138
+ }
139
+ self . add ( render_resolution_simple ( RenderContext :: new ( ctx) , local_name, resolution) ) ;
140
+ }
141
+
142
+ pub ( crate ) fn add_macro (
143
+ & mut self ,
144
+ ctx : & CompletionContext ,
145
+ mac : hir:: Macro ,
146
+ local_name : hir:: Name ,
147
+ ) {
148
+ let is_private_editable = match ctx. is_visible ( & mac) {
149
+ Visible :: Yes => false ,
150
+ Visible :: Editable => true ,
151
+ Visible :: No => return ,
152
+ } ;
153
+ self . add ( render_macro (
154
+ RenderContext :: new ( ctx) . private_editable ( is_private_editable) ,
155
+ local_name,
156
+ mac,
157
+ ) ) ;
128
158
}
129
159
130
160
pub ( crate ) fn add_function (
@@ -138,7 +168,11 @@ impl Completions {
138
168
Visible :: Editable => true ,
139
169
Visible :: No => return ,
140
170
} ;
141
- self . add ( render_fn ( RenderContext :: new ( ctx, is_private_editable) , None , local_name, func) ) ;
171
+ self . add ( render_fn (
172
+ RenderContext :: new ( ctx) . private_editable ( is_private_editable) ,
173
+ local_name,
174
+ func,
175
+ ) ) ;
142
176
}
143
177
144
178
pub ( crate ) fn add_method (
@@ -154,8 +188,7 @@ impl Completions {
154
188
Visible :: No => return ,
155
189
} ;
156
190
self . add ( render_method (
157
- RenderContext :: new ( ctx, is_private_editable) ,
158
- None ,
191
+ RenderContext :: new ( ctx) . private_editable ( is_private_editable) ,
159
192
receiver,
160
193
local_name,
161
194
func,
@@ -168,7 +201,10 @@ impl Completions {
168
201
Visible :: Editable => true ,
169
202
Visible :: No => return ,
170
203
} ;
171
- self . add_opt ( render_const ( RenderContext :: new ( ctx, is_private_editable) , konst) ) ;
204
+ self . add_opt ( render_const (
205
+ RenderContext :: new ( ctx) . private_editable ( is_private_editable) ,
206
+ konst,
207
+ ) ) ;
172
208
}
173
209
174
210
pub ( crate ) fn add_type_alias ( & mut self , ctx : & CompletionContext , type_alias : hir:: TypeAlias ) {
@@ -177,15 +213,18 @@ impl Completions {
177
213
Visible :: Editable => true ,
178
214
Visible :: No => return ,
179
215
} ;
180
- self . add_opt ( render_type_alias ( RenderContext :: new ( ctx, is_private_editable) , type_alias) ) ;
216
+ self . add_opt ( render_type_alias (
217
+ RenderContext :: new ( ctx) . private_editable ( is_private_editable) ,
218
+ type_alias,
219
+ ) ) ;
181
220
}
182
221
183
222
pub ( crate ) fn add_type_alias_with_eq (
184
223
& mut self ,
185
224
ctx : & CompletionContext ,
186
225
type_alias : hir:: TypeAlias ,
187
226
) {
188
- self . add_opt ( render_type_alias_with_eq ( RenderContext :: new ( ctx, false ) , type_alias) ) ;
227
+ self . add_opt ( render_type_alias_with_eq ( RenderContext :: new ( ctx) , type_alias) ) ;
189
228
}
190
229
191
230
pub ( crate ) fn add_qualified_enum_variant (
@@ -194,8 +233,7 @@ impl Completions {
194
233
variant : hir:: Variant ,
195
234
path : hir:: ModPath ,
196
235
) {
197
- let item = render_variant ( RenderContext :: new ( ctx, false ) , None , None , variant, Some ( path) ) ;
198
- self . add ( item) ;
236
+ self . add_opt ( render_variant_lit ( RenderContext :: new ( ctx) , None , variant, Some ( path) ) ) ;
199
237
}
200
238
201
239
pub ( crate ) fn add_enum_variant (
@@ -204,8 +242,7 @@ impl Completions {
204
242
variant : hir:: Variant ,
205
243
local_name : Option < hir:: Name > ,
206
244
) {
207
- let item = render_variant ( RenderContext :: new ( ctx, false ) , None , local_name, variant, None ) ;
208
- self . add ( item) ;
245
+ self . add_opt ( render_variant_lit ( RenderContext :: new ( ctx) , local_name, variant, None ) ) ;
209
246
}
210
247
211
248
pub ( crate ) fn add_field (
@@ -220,7 +257,12 @@ impl Completions {
220
257
Visible :: Editable => true ,
221
258
Visible :: No => return ,
222
259
} ;
223
- let item = render_field ( RenderContext :: new ( ctx, is_private_editable) , receiver, field, ty) ;
260
+ let item = render_field (
261
+ RenderContext :: new ( ctx) . private_editable ( is_private_editable) ,
262
+ receiver,
263
+ field,
264
+ ty,
265
+ ) ;
224
266
self . add ( item) ;
225
267
}
226
268
@@ -231,7 +273,7 @@ impl Completions {
231
273
path : Option < hir:: ModPath > ,
232
274
local_name : Option < hir:: Name > ,
233
275
) {
234
- let item = render_struct_literal ( RenderContext :: new ( ctx, false ) , strukt, path, local_name) ;
276
+ let item = render_struct_literal ( RenderContext :: new ( ctx) , strukt, path, local_name) ;
235
277
self . add_opt ( item) ;
236
278
}
237
279
@@ -242,7 +284,7 @@ impl Completions {
242
284
path : Option < hir:: ModPath > ,
243
285
local_name : Option < hir:: Name > ,
244
286
) {
245
- let item = render_union_literal ( RenderContext :: new ( ctx, false ) , un, path, local_name) ;
287
+ let item = render_union_literal ( RenderContext :: new ( ctx) , un, path, local_name) ;
246
288
self . add_opt ( item) ;
247
289
}
248
290
@@ -253,7 +295,7 @@ impl Completions {
253
295
field : usize ,
254
296
ty : & hir:: Type ,
255
297
) {
256
- let item = render_tuple_field ( RenderContext :: new ( ctx, false ) , receiver, field, ty) ;
298
+ let item = render_tuple_field ( RenderContext :: new ( ctx) , receiver, field, ty) ;
257
299
self . add ( item) ;
258
300
}
259
301
@@ -272,7 +314,14 @@ impl Completions {
272
314
variant : hir:: Variant ,
273
315
local_name : Option < hir:: Name > ,
274
316
) {
275
- self . add_opt ( render_variant_pat ( RenderContext :: new ( ctx, false ) , variant, local_name, None ) ) ;
317
+ self . add_opt ( render_variant_pat (
318
+ RenderContext :: new ( ctx) ,
319
+ variant,
320
+ local_name. clone ( ) ,
321
+ None ,
322
+ false ,
323
+ ) ) ;
324
+ self . add_opt ( render_variant_pat ( RenderContext :: new ( ctx) , variant, local_name, None , true ) ) ;
276
325
}
277
326
278
327
pub ( crate ) fn add_qualified_variant_pat (
@@ -281,7 +330,9 @@ impl Completions {
281
330
variant : hir:: Variant ,
282
331
path : hir:: ModPath ,
283
332
) {
284
- self . add_opt ( render_variant_pat ( RenderContext :: new ( ctx, false ) , variant, None , Some ( path) ) ) ;
333
+ let path = Some ( & path) ;
334
+ self . add_opt ( render_variant_pat ( RenderContext :: new ( ctx) , variant, None , path, false ) ) ;
335
+ self . add_opt ( render_variant_pat ( RenderContext :: new ( ctx) , variant, None , path, true ) ) ;
285
336
}
286
337
287
338
pub ( crate ) fn add_struct_pat (
@@ -290,7 +341,7 @@ impl Completions {
290
341
strukt : hir:: Struct ,
291
342
local_name : Option < hir:: Name > ,
292
343
) {
293
- self . add_opt ( render_struct_pat ( RenderContext :: new ( ctx, false ) , strukt, local_name) ) ;
344
+ self . add_opt ( render_struct_pat ( RenderContext :: new ( ctx) , strukt, local_name) ) ;
294
345
}
295
346
}
296
347
0 commit comments