mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 17:53:56 +00:00
split detail function
This commit is contained in:
parent
9f3d627681
commit
10fae62820
@ -98,9 +98,14 @@ fn render(
|
||||
_ => (),
|
||||
}
|
||||
|
||||
let detail = if ctx.completion.config.full_function_signatures {
|
||||
detail_full(db, func)
|
||||
} else {
|
||||
detail(db, func)
|
||||
};
|
||||
item.set_documentation(ctx.docs(func))
|
||||
.set_deprecated(ctx.is_deprecated(func) || ctx.is_deprecated_assoc_item(func))
|
||||
.detail(detail(db, func, ctx.completion.config.full_function_signatures))
|
||||
.detail(detail)
|
||||
.lookup_by(name.unescaped().to_smol_str());
|
||||
|
||||
match ctx.completion.config.snippet_cap {
|
||||
@ -239,22 +244,7 @@ fn ref_of_param(ctx: &CompletionContext<'_>, arg: &str, ty: &hir::Type) -> &'sta
|
||||
""
|
||||
}
|
||||
|
||||
fn detail(db: &dyn HirDatabase, func: hir::Function, full_function_signature: bool) -> String {
|
||||
if full_function_signature {
|
||||
let signature = format!("{}", func.display(db));
|
||||
let mut singleline = String::with_capacity(signature.len());
|
||||
|
||||
for segment in signature.split_whitespace() {
|
||||
if !singleline.is_empty() {
|
||||
singleline.push(' ');
|
||||
}
|
||||
|
||||
singleline.push_str(segment);
|
||||
}
|
||||
|
||||
return singleline;
|
||||
}
|
||||
|
||||
fn detail(db: &dyn HirDatabase, func: hir::Function) -> String {
|
||||
let mut ret_ty = func.ret_type(db);
|
||||
let mut detail = String::new();
|
||||
|
||||
@ -278,6 +268,21 @@ fn detail(db: &dyn HirDatabase, func: hir::Function, full_function_signature: bo
|
||||
detail
|
||||
}
|
||||
|
||||
fn detail_full(db: &dyn HirDatabase, func: hir::Function) -> String {
|
||||
let signature = format!("{}", func.display(db));
|
||||
let mut detail = String::with_capacity(signature.len());
|
||||
|
||||
for segment in signature.split_whitespace() {
|
||||
if !detail.is_empty() {
|
||||
detail.push(' ');
|
||||
}
|
||||
|
||||
detail.push_str(segment);
|
||||
}
|
||||
|
||||
detail
|
||||
}
|
||||
|
||||
fn params_display(db: &dyn HirDatabase, func: hir::Function) -> String {
|
||||
if let Some(self_param) = func.self_param(db) {
|
||||
let assoc_fn_params = func.assoc_fn_params(db);
|
||||
|
Loading…
Reference in New Issue
Block a user