about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvxpm <viniciusximenespm@gmail.com>2023-09-23 19:43:19 -0300
committervxpm <viniciusximenespm@gmail.com>2023-09-23 19:43:19 -0300
commit10fae6282070945531853901cc19155f59758bbc (patch)
tree74ed2309f2ef2b7b4d281a3d93a3707aff91654a
parent9f3d627681e069ea313076ce65cbd28a8dfe0974 (diff)
downloadrust-10fae6282070945531853901cc19155f59758bbc.tar.gz
rust-10fae6282070945531853901cc19155f59758bbc.zip
split detail function
-rw-r--r--crates/ide-completion/src/render/function.rs39
1 files changed, 22 insertions, 17 deletions
diff --git a/crates/ide-completion/src/render/function.rs b/crates/ide-completion/src/render/function.rs
index dd7de72190d..dfae715afe3 100644
--- a/crates/ide-completion/src/render/function.rs
+++ b/crates/ide-completion/src/render/function.rs
@@ -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);