enhance the signature help (#6606)

update with test

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2025-04-30 13:58:46 -07:00
committed by GitHub
parent 1a6b147107
commit 012102fe86
2 changed files with 78 additions and 11 deletions

View File

@ -533,14 +533,18 @@ pub trait StdLibFn: std::fmt::Debug + Send + Sync {
SignatureHelp {
signatures: vec![SignatureInformation {
label: self.name(),
label: self.fn_signature(true),
documentation: Some(Documentation::MarkupContent(MarkupContent {
kind: MarkupKind::Markdown,
value: if !self.description().is_empty() {
format!("{}\n\n{}", self.summary(), self.description())
} else {
self.summary()
},
value: format!(
r#"{}
{}"#,
self.summary(),
self.description()
)
.trim()
.to_string(),
})),
parameters: Some(self.args(true).into_iter().map(|arg| arg.into()).collect()),
active_parameter,
@ -1116,4 +1120,21 @@ mod tests {
let kcl_std = crate::docs::kcl_doc::walk_prelude();
crate::lsp::kcl::get_signatures_from_stdlib(&stdlib, &kcl_std);
}
#[test]
fn get_extrude_signature_help() {
let extrude_fn: Box<dyn StdLibFn> = Box::new(crate::std::extrude::Extrude);
let sh = extrude_fn.to_signature_help();
assert_eq!(
sh.signatures[0].label,
r#"extrude(
sketches: [Sketch],
length: number,
symmetric?: bool,
bidirectionalLength?: number,
tagStart?: TagNode,
tagEnd?: TagNode,
): [Solid]"#
);
}
}