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

Function groupEnd

src/extraction/languages/objcpp.ts:216–231  ·  view source on GitHub ↗

Past the bracket group opening at `i`, strings and comments inside skipped; -1 when it doesn't close.

(source: string, i: number, open: number, close: number)

Source from the content-addressed store, hash-verified

214
215/** Past the bracket group opening at `i`, strings and comments inside skipped; -1 when it doesn't close. */
216function groupEnd(source: string, i: number, open: number, close: number): number {
217 let depth = 0;
218 for (let j = i; j < source.length; j++) {
219 const c = source.charCodeAt(j);
220 if (c === QUOTE || c === APOSTROPHE) j = quotedEnd(source, j) - 1;
221 else if (c === SLASH && source.charCodeAt(j + 1) === SLASH) j = lineCommentEnd(source, j + 2) - 1;
222 else if (c === SLASH && source.charCodeAt(j + 1) === STAR) {
223 const end = source.indexOf('*/', j + 2);
224 if (end < 0) return -1;
225 j = end + 1;
226 } else if (c === open) depth++;
227 else if (c === close && --depth === 0) return j + 1;
228 else if (c === SEMICOLON || c === LBRACE) return -1;
229 }
230 return -1;
231}
232
233/**
234 * Split an Objective-C++ file into what the Objective-C grammar reads and what

Callers 1

scanItemFunction · 0.70

Calls 2

quotedEndFunction · 0.90
lineCommentEndFunction · 0.90

Tested by

no test coverage detected