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

Function parenGroupEnd

src/extraction/languages/cpp-brace-scopes.ts:139–148  ·  view source on GitHub ↗

Past the `(…)` group at `i` (strings inside skipped), or -1.

(source: string, i: number)

Source from the content-addressed store, hash-verified

137
138/** Past the `(…)` group at `i` (strings inside skipped), or -1. */
139function parenGroupEnd(source: string, i: number): number {
140 let depth = 0;
141 for (let j = i; j < source.length; j++) {
142 const c = source.charCodeAt(j);
143 if (c === 34 || c === 39) j = quotedEnd(source, j) - 1;
144 else if (c === 40) depth++;
145 else if (c === 41 && --depth === 0) return j + 1;
146 }
147 return -1;
148}
149
150/** Past the string or character literal whose quote is at `i` (it stops at a newline). */
151function quotedEnd(source: string, i: number): number {

Callers 1

namespaceHeadFunction · 0.85

Calls 1

quotedEndFunction · 0.70

Tested by

no test coverage detected