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

Function expressionEnd

src/resolution/angular-template-synthesizer.ts:333–349  ·  view source on GitHub ↗

* Where the expression starting at `from` ends: a `;` or `,` outside any * bracket, or the words `as` / `let` that open the next microsyntax binding.

(text: string, from: number)

Source from the content-addressed store, hash-verified

331 * bracket, or the words `as` / `let` that open the next microsyntax binding.
332 */
333function expressionEnd(text: string, from: number): number {
334 let depth = 0;
335 for (let i = from; i < text.length; i++) {
336 const ch = text[i]!;
337 if (ch === '"' || ch === "'" || ch === '`') {
338 const end = skipString(text, i);
339 if (end < 0) return text.length;
340 i = end;
341 continue;
342 }
343 if (ch === '(' || ch === '[' || ch === '{') depth++;
344 else if (ch === ')' || ch === ']' || ch === '}') depth--;
345 else if (depth === 0 && (ch === ';' || ch === ',')) return i;
346 else if (depth === 0 && isBlank(text[i - 1]) && /^(?:as|let)(?![\w$])/.test(text.slice(i, i + 4))) return i;
347 }
348 return text.length;
349}
350
351/** `text` split at each `;` outside brackets and strings, with each part's offset. */
352function topLevelParts(text: string): Array<{ at: number; text: string }> {

Callers 1

readMicrosyntaxFunction · 0.70

Calls 2

skipStringFunction · 0.90
isBlankFunction · 0.70

Tested by

no test coverage detected