mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
Provide only explicit constructor for RenderContext
This commit is contained in:
parent
2a214e15d3
commit
caf0fa20a7
2 changed files with 14 additions and 16 deletions
|
@ -52,12 +52,12 @@ impl Completions {
|
|||
}
|
||||
|
||||
pub(crate) fn add_field(&mut self, ctx: &CompletionContext, field: hir::Field, ty: &Type) {
|
||||
let item = Render::new(ctx.into()).add_field(field, ty);
|
||||
let item = Render::new(RenderContext::new(ctx)).add_field(field, ty);
|
||||
self.add(item);
|
||||
}
|
||||
|
||||
pub(crate) fn add_tuple_field(&mut self, ctx: &CompletionContext, field: usize, ty: &Type) {
|
||||
let item = Render::new(ctx.into()).add_tuple_field(field, ty);
|
||||
let item = Render::new(RenderContext::new(ctx)).add_tuple_field(field, ty);
|
||||
self.add(item);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,9 @@ impl Completions {
|
|||
local_name: String,
|
||||
resolution: &ScopeDef,
|
||||
) {
|
||||
if let Some(item) = Render::new(ctx.into()).render_resolution(local_name, resolution) {
|
||||
if let Some(item) =
|
||||
Render::new(RenderContext::new(ctx)).render_resolution(local_name, resolution)
|
||||
{
|
||||
self.add(item);
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +84,7 @@ impl Completions {
|
|||
Some(it) => it,
|
||||
None => return,
|
||||
};
|
||||
if let Some(item) = MacroRender::new(ctx.into(), name, macro_).render() {
|
||||
if let Some(item) = MacroRender::new(RenderContext::new(ctx), name, macro_).render() {
|
||||
self.add(item);
|
||||
}
|
||||
}
|
||||
|
@ -93,18 +95,18 @@ impl Completions {
|
|||
func: hir::Function,
|
||||
local_name: Option<String>,
|
||||
) {
|
||||
let item = FunctionRender::new(ctx.into(), local_name, func).render();
|
||||
let item = FunctionRender::new(RenderContext::new(ctx), local_name, func).render();
|
||||
self.add(item)
|
||||
}
|
||||
|
||||
pub(crate) fn add_const(&mut self, ctx: &CompletionContext, constant: hir::Const) {
|
||||
if let Some(item) = ConstRender::new(ctx.into(), constant).render() {
|
||||
if let Some(item) = ConstRender::new(RenderContext::new(ctx), constant).render() {
|
||||
self.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn add_type_alias(&mut self, ctx: &CompletionContext, type_alias: hir::TypeAlias) {
|
||||
if let Some(item) = TypeAliasRender::new(ctx.into(), type_alias).render() {
|
||||
if let Some(item) = TypeAliasRender::new(RenderContext::new(ctx), type_alias).render() {
|
||||
self.add(item)
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +117,8 @@ impl Completions {
|
|||
variant: hir::EnumVariant,
|
||||
path: ModPath,
|
||||
) {
|
||||
let item = EnumVariantRender::new(ctx.into(), None, variant, Some(path)).render();
|
||||
let item =
|
||||
EnumVariantRender::new(RenderContext::new(ctx), None, variant, Some(path)).render();
|
||||
self.add(item);
|
||||
}
|
||||
|
||||
|
@ -125,7 +128,8 @@ impl Completions {
|
|||
variant: hir::EnumVariant,
|
||||
local_name: Option<String>,
|
||||
) {
|
||||
let item = EnumVariantRender::new(ctx.into(), local_name, variant, None).render();
|
||||
let item =
|
||||
EnumVariantRender::new(RenderContext::new(ctx), local_name, variant, None).render();
|
||||
self.add(item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ pub(crate) struct RenderContext<'a> {
|
|||
}
|
||||
|
||||
impl<'a> RenderContext<'a> {
|
||||
fn new(completion: &'a CompletionContext<'a>) -> RenderContext<'a> {
|
||||
pub(crate) fn new(completion: &'a CompletionContext<'a>) -> RenderContext<'a> {
|
||||
RenderContext { completion }
|
||||
}
|
||||
|
||||
|
@ -74,12 +74,6 @@ impl<'a> RenderContext<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a CompletionContext<'a>> for RenderContext<'a> {
|
||||
fn from(ctx: &'a CompletionContext<'a>) -> RenderContext<'a> {
|
||||
RenderContext::new(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<'a> {
|
||||
pub(crate) fn new(ctx: RenderContext<'a>) -> Render<'a> {
|
||||
Render { ctx }
|
||||
|
|
Loading…
Reference in a new issue