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

Function semicolonEnd

src/extraction/languages/pascal-preparse.ts:216–236  ·  view source on GitHub ↗

The index after the first `;` from `i` outside parentheses and brackets, or -1 when none comes within `max` characters.

(s: string, i: number, max: number)

Source from the content-addressed store, hash-verified

214
215/** The index after the first `;` from `i` outside parentheses and brackets, or -1 when none comes within `max` characters. */
216function semicolonEnd(s: string, i: number, max: number): number {
217 const limit = Math.min(s.length, i + max);
218 let depth = 0;
219 while (i < limit) {
220 const k = commentOrStringEnd(s, i);
221 if (k >= 0) {
222 i = k;
223 continue;
224 }
225 const c = s.charCodeAt(i);
226 if (c === CH_LPAREN || c === CH_LBRACKET) {
227 depth++;
228 } else if (c === CH_RPAREN || c === CH_RBRACKET) {
229 depth--;
230 } else if (c === CH_SEMI && depth <= 0) {
231 return i + 1;
232 }
233 i++;
234 }
235 return -1;
236}
237
238/**
239 * The index after the `]` closing the attribute group whose `[` is at `i`,

Callers 3

scanPropertyOverrideFunction · 0.85
preParsePascalFunction · 0.85

Calls 1

commentOrStringEndFunction · 0.85

Tested by

no test coverage detected