Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide_completion/src/render/variant.rs')
-rw-r--r--crates/ide_completion/src/render/variant.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/crates/ide_completion/src/render/variant.rs b/crates/ide_completion/src/render/variant.rs
index e6a92f387e..a37b4237c4 100644
--- a/crates/ide_completion/src/render/variant.rs
+++ b/crates/ide_completion/src/render/variant.rs
@@ -1,6 +1,6 @@
//! Code common to structs, unions, and enum variants.
-use crate::render::RenderContext;
+use crate::context::CompletionContext;
use hir::{db::HirDatabase, HasAttrs, HasVisibility, HirDisplay, StructKind};
use ide_db::SnippetCap;
use itertools::Itertools;
@@ -16,11 +16,11 @@ pub(crate) struct RenderedLiteral {
/// Render a record type (or sub-type) to a `RenderedCompound`. Use `None` for
/// the `name` argument for an anonymous type.
-pub(crate) fn render_record(
+pub(crate) fn render_record_lit(
db: &dyn HirDatabase,
snippet_cap: Option<SnippetCap>,
fields: &[hir::Field],
- name: Option<&str>,
+ path: &str,
) -> RenderedLiteral {
let completions = fields.iter().enumerate().format_with(", ", |(idx, field), f| {
if snippet_cap.is_some() {
@@ -35,18 +35,18 @@ pub(crate) fn render_record(
});
RenderedLiteral {
- literal: format!("{} {{ {} }}", name.unwrap_or(""), completions),
- detail: format!("{} {{ {} }}", name.unwrap_or(""), types),
+ literal: format!("{} {{ {} }}", path, completions),
+ detail: format!("{} {{ {} }}", path, types),
}
}
/// Render a tuple type (or sub-type) to a `RenderedCompound`. Use `None` for
/// the `name` argument for an anonymous type.
-pub(crate) fn render_tuple(
+pub(crate) fn render_tuple_lit(
db: &dyn HirDatabase,
snippet_cap: Option<SnippetCap>,
fields: &[hir::Field],
- name: Option<&str>,
+ path: &str,
) -> RenderedLiteral {
let completions = fields.iter().enumerate().format_with(", ", |(idx, _), f| {
if snippet_cap.is_some() {
@@ -59,8 +59,8 @@ pub(crate) fn render_tuple(
let types = fields.iter().format_with(", ", |field, f| f(&field.ty(db).display(db)));
RenderedLiteral {
- literal: format!("{}({})", name.unwrap_or(""), completions),
- detail: format!("{}({})", name.unwrap_or(""), types),
+ literal: format!("{}({})", path, completions),
+ detail: format!("{}({})", path, types),
}
}
@@ -68,20 +68,20 @@ pub(crate) fn render_tuple(
/// fields, plus a boolean for whether the list is comprehensive (contains no
/// private fields and its item is not marked `#[non_exhaustive]`).
pub(crate) fn visible_fields(
- ctx: &RenderContext<'_>,
+ ctx: &CompletionContext,
fields: &[hir::Field],
item: impl HasAttrs,
) -> Option<(Vec<hir::Field>, bool)> {
- let module = ctx.completion.module?;
+ let module = ctx.module?;
let n_fields = fields.len();
let fields = fields
.iter()
- .filter(|field| field.is_visible_from(ctx.db(), module))
+ .filter(|field| field.is_visible_from(ctx.db, module))
.copied()
.collect::<Vec<_>>();
let fields_omitted =
- n_fields - fields.len() > 0 || item.attrs(ctx.db()).by_key("non_exhaustive").exists();
+ n_fields - fields.len() > 0 || item.attrs(ctx.db).by_key("non_exhaustive").exists();
Some((fields, fields_omitted))
}