mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Get rid of do-er antipattern
This commit is contained in:
parent
caf0fa20a7
commit
4d333ebb63
7 changed files with 100 additions and 45 deletions
|
@ -8,8 +8,16 @@ use crate::{
|
|||
render::{builder_ext::Params, RenderContext},
|
||||
};
|
||||
|
||||
pub(crate) fn render_fn<'a>(
|
||||
ctx: RenderContext<'a>,
|
||||
local_name: Option<String>,
|
||||
fn_: hir::Function,
|
||||
) -> CompletionItem {
|
||||
FunctionRender::new(ctx, local_name, fn_).render()
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct FunctionRender<'a> {
|
||||
struct FunctionRender<'a> {
|
||||
ctx: RenderContext<'a>,
|
||||
name: String,
|
||||
fn_: hir::Function,
|
||||
|
@ -17,7 +25,7 @@ pub(crate) struct FunctionRender<'a> {
|
|||
}
|
||||
|
||||
impl<'a> FunctionRender<'a> {
|
||||
pub(crate) fn new(
|
||||
fn new(
|
||||
ctx: RenderContext<'a>,
|
||||
local_name: Option<String>,
|
||||
fn_: hir::Function,
|
||||
|
@ -28,7 +36,7 @@ impl<'a> FunctionRender<'a> {
|
|||
FunctionRender { ctx, name, fn_, ast_node }
|
||||
}
|
||||
|
||||
pub(crate) fn render(self) -> CompletionItem {
|
||||
fn render(self) -> CompletionItem {
|
||||
let params = self.params();
|
||||
CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), self.name.clone())
|
||||
.kind(self.kind())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue