(boundary: WireFlowBoundary)
| 139 | const plural = (n: number, one: string, many: string): string => (n === 1 ? one : many); |
| 140 | |
| 141 | export function endCapText(boundary: WireFlowBoundary): EndCapText { |
| 142 | const sites: EndCapSite[] = boundary.sites.map((site) => { |
| 143 | const notes: string[] = []; |
| 144 | if (site.key === null) notes.push('the key is a runtime value'); |
| 145 | if (site.moreSites > 0) { |
| 146 | notes.push(`+${site.moreSites} more such ${plural(site.moreSites, 'site', 'sites')} here`); |
| 147 | } |
| 148 | return { |
| 149 | headline: `${site.label} at line ${site.line}`, |
| 150 | key: site.key, |
| 151 | notes, |
| 152 | candidates: site.candidates, |
| 153 | candidateHeading: |
| 154 | site.candidates.length > 0 |
| 155 | ? `${site.candidates.length} candidate ${plural(site.candidates.length, 'target', 'targets')} \u203a` |
| 156 | : null, |
| 157 | candidateNote: site.candidateNote, |
| 158 | }; |
| 159 | }); |
| 160 | |
| 161 | const missedNames = boundary.missed.map((m) => m.name); |
| 162 | return { |
| 163 | intro: |
| 164 | boundary.sites.length > 0 |
| 165 | ? `${boundary.node.name} chooses its next call at runtime.` |
| 166 | : `${boundary.node.name} is the last symbol on this path.`, |
| 167 | sites, |
| 168 | quiet: |
| 169 | boundary.sites.length > 0 |
| 170 | ? null |
| 171 | : 'No dynamic-dispatch site was detected in its body, so nothing here explains the break.', |
| 172 | uncertainHeading: |
| 173 | boundary.uncertain.total > 0 |
| 174 | ? `${boundary.uncertain.total} name-only ${plural(boundary.uncertain.total, 'match', 'matches')} not followed (confidence < 0.6)` |
| 175 | : null, |
| 176 | uncertain: boundary.uncertain.items, |
| 177 | further: |
| 178 | boundary.further.total > 0 |
| 179 | ? `It makes ${boundary.further.total} further resolved ${plural(boundary.further.total, 'call', 'calls')} this path does not need.` |
| 180 | : null, |
| 181 | missed: |
| 182 | missedNames.length > 0 |
| 183 | ? `Never reaches ${missedNames.join(', ')}${boundary.missed.length < missedNames.length ? '…' : '.'}` |
| 184 | : null, |
| 185 | }; |
| 186 | } |
| 187 | |
| 188 | /** Exact rendered height of an end cap, which its CSS then pins as a minimum. */ |
| 189 | export function endCapHeight(boundary: WireFlowBoundary): number { |
no test coverage detected