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

Function blockEnd

src/resolution/frameworks/react.ts:2344–2358  ·  view source on GitHub ↗

* The index of the brace closing the block at `open`, or -1. A quote right * after a word is an apostrophe in JSX text (` Don't `), not a string.

(safe: string, open: number)

Source from the content-addressed store, hash-verified

2342 * after a word is an apostrophe in JSX text (`<p>Don't</p>`), not a string.
2343 */
2344function blockEnd(safe: string, open: number): number {
2345 let depth = 0;
2346 for (let i = open; i < safe.length; i++) {
2347 if (opensString(safe, i)) {
2348 const end = skipString(safe, i);
2349 if (end < 0) return -1;
2350 i = end;
2351 continue;
2352 }
2353 const ch = safe[i]!;
2354 if (ch === '{' || ch === '(' || ch === '[') depth++;
2355 else if ((ch === '}' || ch === ')' || ch === ']') && --depth === 0) return i;
2356 }
2357 return -1;
2358}
2359
2360/** True for a quote that opens a string or template, not an apostrophe in JSX text. */
2361function opensString(safe: string, i: number): boolean {

Callers 3

functionBodyFunction · 0.70
pastBodyFunction · 0.70
ownReturnsFunction · 0.70

Calls 2

skipStringFunction · 0.90
opensStringFunction · 0.85

Tested by

no test coverage detected