Build a docblock snippet for a class, interface, trait, or enum. Generates `@extends` / `@implements` tags with tab-stop placeholders when the parent or interface has `@template` parameters.
(
sym: &SymbolInfo,
_indent: &str,
class_loader: &dyn Fn(&str) -> Option<Arc<ClassInfo>>,
)
| 1622 | /// Generates `@extends` / `@implements` tags with tab-stop placeholders |
| 1623 | /// when the parent or interface has `@template` parameters. |
| 1624 | fn build_class_snippet( |
| 1625 | sym: &SymbolInfo, |
| 1626 | _indent: &str, |
| 1627 | class_loader: &dyn Fn(&str) -> Option<Arc<ClassInfo>>, |
| 1628 | ) -> String { |
| 1629 | let mut tag_lines = Vec::new(); |
| 1630 | let mut tab_stop = 1u32; |
| 1631 | |
| 1632 | for parent in &sym.extends_names { |
| 1633 | if let Some(cls) = class_loader(parent) |
| 1634 | && !cls.template_params.is_empty() |
| 1635 | { |
| 1636 | let mut parts = Vec::new(); |
| 1637 | for tp in &cls.template_params { |
| 1638 | parts.push(format!("${{{}:{}}}", tab_stop, tp)); |
| 1639 | tab_stop += 1; |
| 1640 | } |
| 1641 | tag_lines.push(format!(" * @extends {}<{}>", parent, parts.join(", "))); |
| 1642 | } |
| 1643 | } |
| 1644 | |
| 1645 | for iface in &sym.implements_names { |
| 1646 | if let Some(cls) = class_loader(iface) |
| 1647 | && !cls.template_params.is_empty() |
| 1648 | { |
| 1649 | let mut parts = Vec::new(); |
| 1650 | for tp in &cls.template_params { |
| 1651 | parts.push(format!("${{{}:{}}}", tab_stop, tp)); |
| 1652 | tab_stop += 1; |
| 1653 | } |
| 1654 | tag_lines.push(format!(" * @implements {}<{}>", iface, parts.join(", "))); |
| 1655 | } |
| 1656 | } |
| 1657 | |
| 1658 | let mut lines = Vec::new(); |
| 1659 | lines.push("/**".to_string()); |
| 1660 | |
| 1661 | if tag_lines.is_empty() { |
| 1662 | // No template tags — emit a summary-only skeleton. |
| 1663 | lines.push(" * ${1}".to_string()); |
| 1664 | } else { |
| 1665 | lines.extend(tag_lines); |
| 1666 | } |
| 1667 | |
| 1668 | lines.push(" */".to_string()); |
| 1669 | lines.join("\n") |
| 1670 | } |
| 1671 | |
| 1672 | /// Build a docblock snippet for a property. |
| 1673 | /// |