format!("fn {}(..)", fn_name)
};
- let builder = CompletionItem::new(CompletionKind::Magic, ctx.source_range(), label)
- .lookup_by(fn_name)
- .set_documentation(func.docs(ctx.db));
+ let mut builder = CompletionItem::new(CompletionKind::Magic, ctx.source_range(), label);
+ builder.lookup_by(fn_name).set_documentation(func.docs(ctx.db));
let completion_kind = if func.self_param(ctx.db).is_some() {
CompletionItemKind::Method
match ctx.config.snippet_cap {
Some(cap) => {
let snippet = format!("{} {{\n $0\n}}", function_decl);
- builder.snippet_edit(cap, TextEdit::replace(range, snippet))
+ builder.snippet_edit(cap, TextEdit::replace(range, snippet));
}
None => {
let header = format!("{} {{", function_decl);
- builder.text_edit(TextEdit::replace(range, header))
+ builder.text_edit(TextEdit::replace(range, header));
}
- }
- .kind(completion_kind)
- .add_to(acc);
+ };
+ builder.kind(completion_kind);
+ builder.add_to(acc);
}
}
let range = TextRange::new(type_def_node.text_range().start(), ctx.source_range().end());
- CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone())
+ let mut builder =
+ CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone());
+ builder
.text_edit(TextEdit::replace(range, snippet))
.lookup_by(alias_name)
.kind(SymbolKind::TypeAlias)
- .set_documentation(type_alias.docs(ctx.db))
- .add_to(acc);
+ .set_documentation(type_alias.docs(ctx.db));
+ builder.add_to(acc);
}
fn add_const_impl(
let range =
TextRange::new(const_def_node.text_range().start(), ctx.source_range().end());
- CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone())
+ let mut builder =
+ CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone());
+ builder
.text_edit(TextEdit::replace(range, snippet))
.lookup_by(const_name)
.kind(SymbolKind::Const)
- .set_documentation(const_.docs(ctx.db))
- .add_to(acc);
+ .set_documentation(const_.docs(ctx.db));
+ builder.add_to(acc);
}
}
}