MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / build_method_detail

Function build_method_detail

src/document_symbols.rs:386–428  ·  view source on GitHub ↗

Build a detail string for a method showing its signature.

(method: &MethodInfo)

Source from the content-addressed store, hash-verified

384
385/// Build a detail string for a method showing its signature.
386fn build_method_detail(method: &MethodInfo) -> Option<String> {
387 let mut detail = String::new();
388
389 // Visibility prefix.
390 match method.visibility {
391 Visibility::Public => {}
392 Visibility::Protected => detail.push_str("protected "),
393 Visibility::Private => detail.push_str("private "),
394 }
395
396 if method.is_static {
397 detail.push_str("static ");
398 }
399
400 // Parameter list.
401 detail.push('(');
402 let params: Vec<String> = method
403 .parameters
404 .iter()
405 .map(|p| {
406 let mut s = String::new();
407 if let Some(ref t) = p.type_hint {
408 s.push_str(&t.to_string());
409 s.push(' ');
410 }
411 if p.is_variadic {
412 s.push_str("...");
413 }
414 s.push_str(&p.name);
415 s
416 })
417 .collect();
418 detail.push_str(&params.join(", "));
419 detail.push(')');
420
421 // Return type.
422 if let Some(ref ret) = method.return_type {
423 detail.push_str(": ");
424 detail.push_str(&ret.to_string());
425 }
426
427 Some(detail)
428}
429
430/// Build a detail string for a standalone function showing its signature.
431fn build_function_detail(func: &FunctionInfo) -> Option<String> {

Callers 3

method_to_symbolFunction · 0.85

Calls 3

pushMethod · 0.80
iterMethod · 0.80
mapMethod · 0.45

Tested by 2