Skip to content

Commit eed5b46

Browse files
committed
misc improvements
1 parent 251df51 commit eed5b46

2 files changed

Lines changed: 48 additions & 67 deletions

File tree

crates/ide-completion/src/completions.rs

Lines changed: 47 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -234,17 +234,13 @@ impl Completions {
234234
Visible::Editable => true,
235235
Visible::No => return,
236236
};
237-
self.add(
238-
render_path_resolution(
239-
RenderContext::new(ctx)
240-
.private_editable(is_private_editable)
241-
.doc_aliases(doc_aliases),
242-
path_ctx,
243-
local_name,
244-
resolution,
245-
)
246-
.build(ctx.db),
247-
);
237+
render_path_resolution(
238+
RenderContext::new(ctx).private_editable(is_private_editable).doc_aliases(doc_aliases),
239+
path_ctx,
240+
local_name,
241+
resolution,
242+
)
243+
.add_to(self, ctx.db);
248244
}
249245

250246
pub(crate) fn add_pattern_resolution(
@@ -259,15 +255,13 @@ impl Completions {
259255
Visible::Editable => true,
260256
Visible::No => return,
261257
};
262-
self.add(
263-
render_pattern_resolution(
264-
RenderContext::new(ctx).private_editable(is_private_editable),
265-
pattern_ctx,
266-
local_name,
267-
resolution,
268-
)
269-
.build(ctx.db),
270-
);
258+
render_pattern_resolution(
259+
RenderContext::new(ctx).private_editable(is_private_editable),
260+
pattern_ctx,
261+
local_name,
262+
resolution,
263+
)
264+
.add_to(self, ctx.db);
271265
}
272266

273267
pub(crate) fn add_enum_variants(
@@ -310,15 +304,13 @@ impl Completions {
310304
Visible::Editable => true,
311305
Visible::No => return,
312306
};
313-
self.add(
314-
render_macro(
315-
RenderContext::new(ctx).private_editable(is_private_editable),
316-
path_ctx,
317-
local_name,
318-
mac,
319-
)
320-
.build(ctx.db),
321-
);
307+
render_macro(
308+
RenderContext::new(ctx).private_editable(is_private_editable),
309+
path_ctx,
310+
local_name,
311+
mac,
312+
)
313+
.add_to(self, ctx.db);
322314
}
323315

324316
pub(crate) fn add_function(
@@ -334,17 +326,13 @@ impl Completions {
334326
Visible::No => return,
335327
};
336328
let doc_aliases = ctx.doc_aliases(&func);
337-
self.add(
338-
render_fn(
339-
RenderContext::new(ctx)
340-
.private_editable(is_private_editable)
341-
.doc_aliases(doc_aliases),
342-
path_ctx,
343-
local_name,
344-
func,
345-
)
346-
.build(ctx.db),
347-
);
329+
render_fn(
330+
RenderContext::new(ctx).private_editable(is_private_editable).doc_aliases(doc_aliases),
331+
path_ctx,
332+
local_name,
333+
func,
334+
)
335+
.add_to(self, ctx.db);
348336
}
349337

350338
pub(crate) fn add_method(
@@ -361,18 +349,14 @@ impl Completions {
361349
Visible::No => return,
362350
};
363351
let doc_aliases = ctx.doc_aliases(&func);
364-
self.add(
365-
render_method(
366-
RenderContext::new(ctx)
367-
.private_editable(is_private_editable)
368-
.doc_aliases(doc_aliases),
369-
dot_access,
370-
receiver,
371-
local_name,
372-
func,
373-
)
374-
.build(ctx.db),
375-
);
352+
render_method(
353+
RenderContext::new(ctx).private_editable(is_private_editable).doc_aliases(doc_aliases),
354+
dot_access,
355+
receiver,
356+
local_name,
357+
func,
358+
)
359+
.add_to(self, ctx.db);
376360
}
377361

378362
pub(crate) fn add_method_with_import(
@@ -388,19 +372,17 @@ impl Completions {
388372
Visible::No => return,
389373
};
390374
let doc_aliases = ctx.doc_aliases(&func);
391-
self.add(
392-
render_method(
393-
RenderContext::new(ctx)
394-
.private_editable(is_private_editable)
395-
.doc_aliases(doc_aliases)
396-
.import_to_add(Some(import)),
397-
dot_access,
398-
None,
399-
None,
400-
func,
401-
)
402-
.build(ctx.db),
403-
);
375+
render_method(
376+
RenderContext::new(ctx)
377+
.private_editable(is_private_editable)
378+
.doc_aliases(doc_aliases)
379+
.import_to_add(Some(import)),
380+
dot_access,
381+
None,
382+
None,
383+
func,
384+
)
385+
.add_to(self, ctx.db);
404386
}
405387

406388
pub(crate) fn add_const(&mut self, ctx: &CompletionContext<'_>, konst: hir::Const) {

crates/ide-completion/src/render.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ impl<'a> RenderContext<'a> {
111111
is_assoc_deprecated
112112
|| assoc
113113
.container_or_implemented_trait(db)
114-
.map(|trait_| self.is_deprecated(trait_))
115-
.unwrap_or(false)
114+
.is_some_and(|trait_| self.is_deprecated(trait_))
116115
}
117116

118117
// FIXME: remove this

0 commit comments

Comments
 (0)