MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / keepEmittedScript

Function keepEmittedScript

src/extraction/razor-script.ts:108–137  ·  view source on GitHub ↗

Keep what a statement block emits as JavaScript, and blank the C# around it.

(s: string, out: string[], from: number, to: number)

Source from the content-addressed store, hash-verified

106
107/** Keep what a statement block emits as JavaScript, and blank the C# around it. */
108function 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. */
140function blankControl(s: string, out: string[], at: number, limit: number): number {

Callers 1

blankControlFunction · 0.85

Calls 3

blankRazorFunction · 0.85
closingTextFunction · 0.85
blankFunction · 0.70

Tested by

no test coverage detected