* The lead paragraph, assembled from the clauses the active lenses allow. * * Each clause is gated by the facet that owns its fact, so a reader who turned * Data off is not told how many environment values there are. The alternative, * one fixed sentence over all three counts, would quietly rein
(ir: SemanticIR, facets: ReadonlySet<Facet>)
| 704 | * the facets were asked to remove. |
| 705 | */ |
| 706 | function overviewClauses(ir: SemanticIR, facets: ReadonlySet<Facet>): string[] { |
| 707 | const clauses = [proseLead(ir.symbol.name, ir.symbol.kind)]; |
| 708 | const absent: string[] = []; |
| 709 | if (facets.has(Facet.Logic) || facets.has(Facet.Calls)) { |
| 710 | const callees = ir.steps.value.map((call) => call.targetName).filter((name) => name.length > 0); |
| 711 | if (callees.length > 0) { |
| 712 | clauses.push(proseCalls(ir.symbol.name, callees)); |
| 713 | } else { |
| 714 | absent.push('outgoing call'); |
| 715 | } |
| 716 | } |
| 717 | if (facets.has(Facet.Data)) { |
| 718 | const reads = ir.reads.value.map((entry) => entry.name).filter((name) => name.length > 0); |
| 719 | if (reads.length > 0) { |
| 720 | clauses.push(proseReads(ir.symbol.name, reads)); |
| 721 | } else if (sharedNames(ir).length === 0) { |
| 722 | absent.push('environment read'); |
| 723 | } |
| 724 | } |
| 725 | if (facets.has(Facet.Errors)) { |
| 726 | const errors = ir.throws.value.map((entry) => entry.type).filter((name) => name.length > 0); |
| 727 | if (errors.length > 0) { |
| 728 | clauses.push(proseThrows(ir.symbol.name, errors)); |
| 729 | } else { |
| 730 | absent.push('stopping error'); |
| 731 | } |
| 732 | } |
| 733 | if (absent.length > 0) { |
| 734 | clauses.push(`The index records no ${joinNames(absent)} for ${ir.symbol.name}.`); |
| 735 | } |
| 736 | return clauses; |
| 737 | } |
| 738 | |
| 739 | /** The first factual sentence on every level, including the positive leaf case. */ |
| 740 | function subjectLine(ir: SemanticIR): string { |
no test coverage detected