Build a detail string for a standalone function showing its signature.
(func: &FunctionInfo)
| 429 | |
| 430 | /// Build a detail string for a standalone function showing its signature. |
| 431 | fn build_function_detail(func: &FunctionInfo) -> Option<String> { |
| 432 | let mut detail = String::new(); |
| 433 | |
| 434 | detail.push('('); |
| 435 | let params: Vec<String> = func |
| 436 | .parameters |
| 437 | .iter() |
| 438 | .map(|p| { |
| 439 | let mut s = String::new(); |
| 440 | if let Some(ref t) = p.type_hint { |
| 441 | s.push_str(&t.to_string()); |
| 442 | s.push(' '); |
| 443 | } |
| 444 | if p.is_variadic { |
| 445 | s.push_str("..."); |
| 446 | } |
| 447 | s.push_str(&p.name); |
| 448 | s |
| 449 | }) |
| 450 | .collect(); |
| 451 | detail.push_str(¶ms.join(", ")); |
| 452 | detail.push(')'); |
| 453 | |
| 454 | if let Some(ref ret) = func.return_type { |
| 455 | detail.push_str(": "); |
| 456 | detail.push_str(&ret.to_string()); |
| 457 | } |
| 458 | |
| 459 | Some(detail) |
| 460 | } |
| 461 | |
| 462 | /// Find the start of a class/interface/trait/enum name token after the |
| 463 | /// keyword at `keyword_offset`. Scans forward past whitespace to find |