Build the body lines for a trait hover showing public member signatures. Shows public methods (one-line signatures without bodies), public properties, and public constants. Uses native types only and short (unqualified) class names for a scannable summary. If there are more than [`MAX_BODY_ITEMS`] members, the list is truncated with a `// and N more…` comment.
(cls: &ClassInfo)
| 1691 | /// If there are more than [`MAX_BODY_ITEMS`] members, the list is |
| 1692 | /// truncated with a `// and N more…` comment. |
| 1693 | fn build_trait_summary_body(cls: &ClassInfo) -> String { |
| 1694 | let mut member_lines: Vec<String> = Vec::new(); |
| 1695 | |
| 1696 | // Public constants. |
| 1697 | for constant in &cls.constants { |
| 1698 | if constant.visibility != Visibility::Public { |
| 1699 | continue; |
| 1700 | } |
| 1701 | let type_hint = constant |
| 1702 | .type_hint |
| 1703 | .as_ref() |
| 1704 | .map(|t| format!(": {}", t)) |
| 1705 | .unwrap_or_default(); |
| 1706 | let value_suffix = constant |
| 1707 | .value |
| 1708 | .as_ref() |
| 1709 | .map(|v| format!(" = {}", v)) |
| 1710 | .unwrap_or_default(); |
| 1711 | member_lines.push(format!( |
| 1712 | " const {}{}{};", |
| 1713 | constant.name, type_hint, value_suffix |
| 1714 | )); |
| 1715 | } |
| 1716 | |
| 1717 | // Public properties. |
| 1718 | for prop in &cls.properties { |
| 1719 | if prop.visibility != Visibility::Public { |
| 1720 | continue; |
| 1721 | } |
| 1722 | let static_kw = if prop.is_static { "static " } else { "" }; |
| 1723 | let native_type = prop |
| 1724 | .native_type_hint |
| 1725 | .as_ref() |
| 1726 | .map(|t| format!("{} ", t)) |
| 1727 | .unwrap_or_default(); |
| 1728 | member_lines.push(format!( |
| 1729 | " public {}{}${};", |
| 1730 | static_kw, native_type, prop.name |
| 1731 | )); |
| 1732 | } |
| 1733 | |
| 1734 | // Public methods. |
| 1735 | for method in &cls.methods { |
| 1736 | if method.visibility != Visibility::Public { |
| 1737 | continue; |
| 1738 | } |
| 1739 | let static_kw = if method.is_static { "static " } else { "" }; |
| 1740 | let native_params = format_native_params(&method.parameters); |
| 1741 | let native_ret = method |
| 1742 | .native_return_type |
| 1743 | .as_ref() |
| 1744 | .map(|r| format!(": {}", r)) |
| 1745 | .unwrap_or_default(); |
| 1746 | member_lines.push(format!( |
| 1747 | " public {}function {}({}){};", |
| 1748 | static_kw, method.name, native_params, native_ret |
| 1749 | )); |
| 1750 | } |
no test coverage detected