(source: Source, names: Map<Name, string>)
| 140 | } |
| 141 | |
| 142 | function sourceLineLength(source: Source, names: Map<Name, string>): number { |
| 143 | switch (source.kind) { |
| 144 | case "text": |
| 145 | return source.text.length; |
| 146 | case "newline": |
| 147 | return panic("Newline must not occur within a line."); |
| 148 | case "sequence": |
| 149 | return source.sequence |
| 150 | .map((s: Source) => sourceLineLength(s, names)) |
| 151 | .reduce((a: number, b: number) => a + b, 0); |
| 152 | case "table": |
| 153 | return panic("Table must not occur within a line."); |
| 154 | case "annotated": |
| 155 | return sourceLineLength(source.source, names); |
| 156 | case "name": |
| 157 | return defined(names.get(source.named)).length; |
| 158 | case "modified": |
| 159 | return serializeRenderResult({ rootSource: source, names }, "").lines.join("\n").length; |
| 160 | default: |
| 161 | return assertNever(source); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | export function serializeRenderResult( |
| 166 | { rootSource, names }: RenderResult, |
no test coverage detected
searching dependent graphs…