Keep what a statement block emits as JavaScript, and blank the C# around it.
(s: string, out: string[], from: number, to: number)
| 106 | |
| 107 | /** Keep what a statement block emits as JavaScript, and blank the C# around it. */ |
| 108 | function keepEmittedScript(s: string, out: string[], from: number, to: number): void { |
| 109 | let i = from; |
| 110 | while (i < to) { |
| 111 | const textTag = s.indexOf('<text>', i); |
| 112 | const lineTag = s.indexOf('@:', i); |
| 113 | const next = [textTag, lineTag].filter((at) => at >= 0 && at < to).sort((a, b) => a - b)[0]; |
| 114 | if (next === undefined) { |
| 115 | blank(out, i, to); |
| 116 | return; |
| 117 | } |
| 118 | blank(out, i, next); |
| 119 | if (next === lineTag) { |
| 120 | const end = s.indexOf('\n', next); |
| 121 | const stop = end < 0 || end > to ? to : end; |
| 122 | blank(out, next, next + 2); |
| 123 | blankRazor(s, out, next + 2, stop); |
| 124 | i = stop; |
| 125 | } else { |
| 126 | const close = closingText(s, next, to); |
| 127 | if (close < 0) { |
| 128 | blank(out, next, to); |
| 129 | return; |
| 130 | } |
| 131 | blank(out, next, next + '<text>'.length); |
| 132 | blankRazor(s, out, next + '<text>'.length, close); |
| 133 | blank(out, close, close + '</text>'.length); |
| 134 | i = close + '</text>'.length; |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | /** Blank a control statement whose keyword starts at `at`; returns where it ends. */ |
| 140 | function blankControl(s: string, out: string[], at: number, limit: number): number { |
no test coverage detected